edu.stanford.protege.webprotege.dispatch.AbstractProjectChangeHandler Maven / Gradle / Ivy
The newest version!
package edu.stanford.protege.webprotege.dispatch;
import edu.stanford.protege.webprotege.access.AccessManager;
import edu.stanford.protege.webprotege.change.ChangeApplicationResult;
import edu.stanford.protege.webprotege.change.ChangeListGenerator;
import edu.stanford.protege.webprotege.change.HasApplyChanges;
import edu.stanford.protege.webprotege.common.Request;
import edu.stanford.protege.webprotege.common.Response;
import edu.stanford.protege.webprotege.ipc.ExecutionContext;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 25/02/2013
*/
public abstract class AbstractProjectChangeHandler, R extends Response> extends AbstractProjectActionHandler {
@Nonnull
private final HasApplyChanges applyChanges;
public AbstractProjectChangeHandler(@Nonnull AccessManager accessManager, @Nonnull HasApplyChanges applyChanges) {
super(accessManager);
this.applyChanges = checkNotNull(applyChanges);
}
@Nonnull
@Override
public final R execute(@Nonnull A action, @Nonnull ExecutionContext executionContext) {
ChangeListGenerator changeListGenerator = getChangeListGenerator(action, executionContext);
ChangeApplicationResult result = applyChanges.applyChanges(executionContext.userId(),
changeListGenerator);
return createActionResult(result, action, executionContext);
}
protected abstract ChangeListGenerator getChangeListGenerator(A action,
ExecutionContext executionContext);
protected abstract R createActionResult(ChangeApplicationResult changeApplicationResult,
A action,
ExecutionContext executionContext);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy