2018-09-04 11:36:18 +02:00
|
|
|
package eu.eudat.logic.managers;
|
|
|
|
|
|
|
|
import eu.eudat.data.entities.Service;
|
|
|
|
import eu.eudat.logic.services.ApiContext;
|
2019-09-25 12:43:17 +02:00
|
|
|
import eu.eudat.models.data.security.Principal;
|
2018-09-04 11:36:18 +02:00
|
|
|
import eu.eudat.models.data.services.ServiceModel;
|
2019-03-05 16:33:59 +01:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Component;
|
2018-09-04 11:36:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by ikalyvas on 9/3/2018.
|
|
|
|
*/
|
2019-03-05 16:33:59 +01:00
|
|
|
@Component
|
2018-09-04 11:36:18 +02:00
|
|
|
public class ServiceManager {
|
2019-03-05 16:33:59 +01:00
|
|
|
|
|
|
|
private ApiContext apiContext;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
public ServiceManager(ApiContext apiContext) {
|
|
|
|
this.apiContext = apiContext;
|
|
|
|
}
|
|
|
|
|
2019-09-25 12:43:17 +02:00
|
|
|
public Service create(ServiceModel serviceModel, Principal principal) throws Exception {
|
2018-09-04 11:36:18 +02:00
|
|
|
Service service = serviceModel.toDataModel();
|
2019-09-25 12:43:17 +02:00
|
|
|
service.getCreationUser().setId(principal.getId());
|
2018-09-04 11:36:18 +02:00
|
|
|
return apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().createOrUpdate(service);
|
|
|
|
}
|
|
|
|
}
|