Search in sources :

Example 1 with ServiceForGUI

use of cz.metacentrum.perun.controller.model.ServiceForGUI in project perun by CESNET.

the class GeneralServiceManagerImpl method getFacilityAssignedServicesForGUI.

@Override
public List<ServiceForGUI> getFacilityAssignedServicesForGUI(PerunSession perunSession, Facility facility) throws PrivilegeException, FacilityNotExistsException, InternalErrorException {
    // result list
    List<ServiceForGUI> result = new ArrayList<ServiceForGUI>();
    // get assigned services
    List<Service> services = getServicesManager().getAssignedServices(perunSession, facility);
    for (Service service : services) {
        // flag
        boolean allowed = true;
        // new ServiceForGUI
        ServiceForGUI newService = new ServiceForGUI(service);
        // get their exec services
        List<ExecService> execs = execServiceDao.listExecServices(service.getId());
        for (ExecService exec : execs) {
            // if generate
            if (exec.getExecServiceType().equals(ExecService.ExecServiceType.GENERATE)) {
                if (execServiceDenialDao.isExecServiceDeniedOnFacility(exec.getId(), facility.getId()) == true) {
                    newService.setGenAllowedOnFacility(false);
                    allowed = false;
                } else {
                    newService.setGenAllowedOnFacility(true);
                }
                newService.setGenExecService(exec);
            } else {
                // if send
                if (execServiceDenialDao.isExecServiceDeniedOnFacility(exec.getId(), facility.getId()) == true) {
                    newService.setSendAllowedOnFacility(false);
                    allowed = false;
                } else {
                    newService.setSendAllowedOnFacility(true);
                }
                newService.setSendExecService(exec);
            }
        }
        newService.setAllowedOnFacility(allowed);
        result.add(newService);
    }
    return result;
}
Also used : ServiceForGUI(cz.metacentrum.perun.controller.model.ServiceForGUI) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) ArrayList(java.util.ArrayList) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) Service(cz.metacentrum.perun.core.api.Service)

Aggregations

ServiceForGUI (cz.metacentrum.perun.controller.model.ServiceForGUI)1 Service (cz.metacentrum.perun.core.api.Service)1 ExecService (cz.metacentrum.perun.taskslib.model.ExecService)1 ArrayList (java.util.ArrayList)1