argos/dmp-backend/web/src/main/java/eu/eudat/controllers/BaseController.java

36 lines
2.0 KiB
Java
Raw Normal View History

2018-01-03 11:44:54 +01:00
package eu.eudat.controllers;
2018-06-27 12:29:21 +02:00
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.validators.*;
2018-01-03 11:44:54 +01:00
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
2018-02-01 10:08:06 +01:00
2018-01-03 11:44:54 +01:00
public abstract class BaseController {
2018-01-04 10:32:39 +01:00
private ApiContext apiContext;
2018-01-03 11:44:54 +01:00
2018-01-04 10:32:39 +01:00
public ApiContext getApiContext() {
return apiContext;
}
2018-02-16 11:34:02 +01:00
public BaseController(ApiContext apiContext) {
2018-10-02 16:33:58 +02:00
2018-01-04 10:32:39 +01:00
this.apiContext = apiContext;
2018-01-03 11:44:54 +01:00
}
@InitBinder()
protected void initBinder(WebDataBinder binder) {
2018-02-16 11:34:02 +01:00
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass())))
2018-03-05 17:18:45 +01:00
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanTableRequestValidator", DataManagementPlanTableRequestValidator.class));
if (binder.getTarget() != null && GrantTableRequestValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("grantTableRequestValidator", GrantTableRequestValidator.class));
2018-02-16 11:34:02 +01:00
if (binder.getTarget() != null && DatasetProfileValidator.supportsType((binder.getTarget().getClass())))
2018-03-05 17:18:45 +01:00
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("datasetProfileValidator", DatasetProfileValidator.class));
if (binder.getTarget() != null && GrantModelValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("grantModelValidator", GrantModelValidator.class));
2018-03-08 11:54:56 +01:00
if (binder.getTarget() != null && DataManagementPlanNewVersionValidator.supportsType((binder.getTarget().getClass())))
binder.addValidators(this.apiContext.getOperationsContext().getApplicationContext().getBean("dataManagementPlanNewVersionValidator", DataManagementPlanNewVersionValidator.class));
2018-01-03 11:44:54 +01:00
}
}