Search in sources :

Example 1 with RenameProjectSuccessPayload

use of org.eclipse.sirius.web.services.api.projects.RenameProjectSuccessPayload in project sirius-web by eclipse-sirius.

the class RenameProjectEventHandler method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IInput input) {
    String message = this.messageService.invalidInput(input.getClass().getSimpleName(), RenameProjectInput.class.getSimpleName());
    IPayload payload = new ErrorPayload(input.getId(), message);
    ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, editingContext.getId(), input);
    if (input instanceof RenameProjectInput) {
        RenameProjectInput renameProjectInput = (RenameProjectInput) input;
        Optional<Project> optionalProject = this.projectService.renameProject(renameProjectInput.getProjectId(), renameProjectInput.getNewName());
        if (optionalProject.isPresent()) {
            payload = new RenameProjectSuccessPayload(input.getId(), optionalProject.get());
            changeDescription = new ChangeDescription(ChangeKind.PROJECT_RENAMING, editingContext.getId(), input);
        }
    }
    payloadSink.tryEmitValue(payload);
    changeDescriptionSink.tryEmitNext(changeDescription);
}
Also used : Project(org.eclipse.sirius.web.services.api.projects.Project) ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) RenameProjectSuccessPayload(org.eclipse.sirius.web.services.api.projects.RenameProjectSuccessPayload) RenameProjectInput(org.eclipse.sirius.web.services.api.projects.RenameProjectInput) IPayload(org.eclipse.sirius.components.core.api.IPayload)

Aggregations

ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 ErrorPayload (org.eclipse.sirius.components.core.api.ErrorPayload)1 IPayload (org.eclipse.sirius.components.core.api.IPayload)1 Project (org.eclipse.sirius.web.services.api.projects.Project)1 RenameProjectInput (org.eclipse.sirius.web.services.api.projects.RenameProjectInput)1 RenameProjectSuccessPayload (org.eclipse.sirius.web.services.api.projects.RenameProjectSuccessPayload)1