public interface ChannelCreateCommand extends DraftBasedCreateCommandDsl<Channel,ChannelDraft,ChannelCreateCommand>, MetaModelReferenceExpansionDsl<Channel,ChannelCreateCommand,ChannelExpansionModel<Channel>>
Example:
final String key = "demo-key"; final Address address = Address.of(DE).withCity("Berlin"); final Point geoLocation = Point.of(52.5200070, 13.4049540); final ChannelDraft channelDraft = ChannelDraft.of(key) .withName(LocalizedString.of(ENGLISH, "name")) .withDescription(LocalizedString.of(ENGLISH, "description")) .withRoles(ChannelRole.INVENTORY_SUPPLY) .withAddress(address) .withGeoLocation(geoLocation); final Channel channel = client().executeBlocking(ChannelCreateCommand.of(channelDraft)); assertThat(channel.getKey()).isEqualTo(key); assertThat(channel.getName()).isEqualTo(LocalizedString.of(ENGLISH, "name")); assertThat(channel.getDescription()).isEqualTo(LocalizedString.of(ENGLISH, "description")); assertThat(channel.getRoles()).isEqualTo(asSet(ChannelRole.INVENTORY_SUPPLY)); assertThat(channel.getAddress()).isEqualTo(address); assertThat(channel.getGeoLocation()).isEqualTo(geoLocation);
See the test code.
Example for creation a channel with custom fields:
withUpdateableType(client(), type -> { final CustomFieldsDraft customFieldsDraft = CustomFieldsDraftBuilder.ofType(type) .addObject(STRING_FIELD_NAME, "a value") .build(); final ChannelDraft channelDraft = ChannelDraft.of(randomKey()).withCustom(customFieldsDraft); final Channel channel = client().executeBlocking(ChannelCreateCommand.of(channelDraft)); assertThat(channel.getCustom().getFieldAsString(STRING_FIELD_NAME)) .isEqualTo("a value"); final ChannelUpdateCommand channelUpdateCommand = ChannelUpdateCommand.of(channel, SetCustomField.ofObject(STRING_FIELD_NAME, "a new value")); final Channel updatedChannel = client().executeBlocking(channelUpdateCommand); assertThat(updatedChannel.getCustom() .getFieldAsString(STRING_FIELD_NAME)).isEqualTo("a new value"); //clean up client().executeBlocking(ChannelDeleteCommand.of(updatedChannel)); return type; });
See the test code.
ChannelDraft
,
Channel
Modifier and Type | Method and Description |
---|---|
static ChannelCreateCommand |
of(ChannelDraft draft)
Creates a command object to create a
Channel . |
getDraft, withDraft
canDeserialize, deserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths
expansionPaths
static ChannelCreateCommand of(ChannelDraft draft)
Channel
.draft
- template to create the new object