Search in sources :

Example 1 with CreateControllerCommand

use of com.canoo.dp.impl.remoting.commands.CreateControllerCommand in project dolphin-platform by canoo.

the class ControllerProxyFactory method create.

public <T> CompletableFuture<ControllerProxy<T>> create(String name, String parentControllerId) {
    Assert.requireNonBlank(name, "name");
    final InternalAttributesBean bean = platformBeanRepository.getInternalAttributesBean();
    final CreateControllerCommand createControllerCommand = new CreateControllerCommand();
    createControllerCommand.setControllerName(name);
    if (parentControllerId != null) {
        createControllerCommand.setParentControllerId(parentControllerId);
    }
    return dolphinCommandHandler.invokeDolphinCommand(createControllerCommand).thenApply(new Function<Void, ControllerProxy<T>>() {

        @Override
        public ControllerProxy<T> apply(Void aVoid) {
            return new ControllerProxyImpl<T>(bean.getControllerId(), (T) bean.getModel(), clientConnector, platformBeanRepository, ControllerProxyFactory.this, converters);
        }
    });
}
Also used : InternalAttributesBean(com.canoo.dp.impl.remoting.InternalAttributesBean) ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) CreateControllerCommand(com.canoo.dp.impl.remoting.commands.CreateControllerCommand)

Example 2 with CreateControllerCommand

use of com.canoo.dp.impl.remoting.commands.CreateControllerCommand in project dolphin-platform by canoo.

the class CreateControllerCommandEncoder method decode.

@Override
public CreateControllerCommand decode(final JsonObject jsonObject) {
    Assert.requireNonNull(jsonObject, "jsonObject");
    try {
        final CreateControllerCommand command = new CreateControllerCommand();
        if (jsonObject.has(CONTROLLER_ID) && !isElementJsonNull(jsonObject, CONTROLLER_ID)) {
            command.setParentControllerId(getStringElement(jsonObject, CONTROLLER_ID));
        }
        command.setControllerName(getStringElement(jsonObject, NAME));
        return command;
    } catch (final Exception ex) {
        throw new JsonParseException("Illegal JSON detected", ex);
    }
}
Also used : JsonParseException(com.google.gson.JsonParseException) JsonParseException(com.google.gson.JsonParseException) CreateControllerCommand(com.canoo.dp.impl.remoting.commands.CreateControllerCommand)

Aggregations

CreateControllerCommand (com.canoo.dp.impl.remoting.commands.CreateControllerCommand)2 InternalAttributesBean (com.canoo.dp.impl.remoting.InternalAttributesBean)1 ControllerProxy (com.canoo.platform.remoting.client.ControllerProxy)1 JsonParseException (com.google.gson.JsonParseException)1