Při vkládání nového požadavku se nabízí pouze střediska nastavená u

daného typu požadavku.
closes #130
multitenant
Josef Rokos 10 years ago
parent 60accd156c
commit 31d5892200

@ -1,10 +1,14 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import java.util.List;
public interface RequirementTypeService extends Service<RequirementType> { public interface RequirementTypeService extends Service<RequirementType> {
public RequirementType getTypeById(String id); public RequirementType getTypeById(String id);
public List<Workgroup> filterCentres(RequirementType reqType, List<Workgroup> source);
} }

@ -1,8 +1,12 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import java.util.ArrayList;
import java.util.List;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
public class RequirementTypeServiceImpl extends AbstractOwnedService<RequirementType> implements RequirementTypeService { public class RequirementTypeServiceImpl extends AbstractOwnedService<RequirementType> implements RequirementTypeService {
@ -13,4 +17,23 @@ public class RequirementTypeServiceImpl extends AbstractOwnedService<Requiremen
return selectSingle("from RequirementType where type = '" + id + "'"); return selectSingle("from RequirementType where type = '" + id + "'");
} }
@Override
public List<Workgroup> filterCentres(RequirementType reqType,
List<Workgroup> source) {
if (!reqType.getLimitCentres()) {
return source;
}
List<Workgroup> filtered = new ArrayList<Workgroup>();
for (Workgroup wg : source) {
if (reqType.getOfferedCentres().contains(wg)) {
filtered.add(wg);
}
}
return filtered;
}
} }

@ -5,6 +5,7 @@ import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementItem; import info.bukova.isspst.data.RequirementItem;
import info.bukova.isspst.data.RequirementSubject; import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.BigDecimalConverter; import info.bukova.isspst.ui.BigDecimalConverter;
@ -36,6 +37,9 @@ public class RequirementForm extends FormViewModel<Requirement>
@WireVariable @WireVariable
private WorkgroupService workgroupService; private WorkgroupService workgroupService;
@WireVariable
private RequirementTypeService reqTypeService;
private RequirementItem selectedItem; private RequirementItem selectedItem;
@ -46,10 +50,12 @@ public class RequirementForm extends FormViewModel<Requirement>
private RequirementFormValidator requirementFormValidator; private RequirementFormValidator requirementFormValidator;
private List<RequirementItem> syncItems; private List<RequirementItem> syncItems;
private List<Workgroup> centres;
public List<Workgroup> getCentres() public List<Workgroup> getCentres()
{ {
return workgroupService.getUserCentres(userService.getCurrent()); return centres;
} }
public RequirementItem getSelectedItem() public RequirementItem getSelectedItem()
@ -91,7 +97,7 @@ public class RequirementForm extends FormViewModel<Requirement>
{ {
this.requirementFormValidator = requirementFormValidator; this.requirementFormValidator = requirementFormValidator;
} }
@Init(superclass = true) @Init(superclass = true)
public void init() public void init()
{ {
@ -99,6 +105,7 @@ public class RequirementForm extends FormViewModel<Requirement>
this.setBigDecimalConverter(new BigDecimalConverter()); this.setBigDecimalConverter(new BigDecimalConverter());
this.setRequirementFormValidator(new RequirementFormValidator()); this.setRequirementFormValidator(new RequirementFormValidator());
this.setSyncItems(this.getDataBean().getItems()); this.setSyncItems(this.getDataBean().getItems());
this.centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
} }
public List<RequirementItem> getSyncItems() public List<RequirementItem> getSyncItems()

@ -12,6 +12,7 @@ import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
@ -26,6 +27,8 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
private WorkgroupService workgroupService; private WorkgroupService workgroupService;
@WireVariable @WireVariable
private GlobalSettingsService settingsService; private GlobalSettingsService settingsService;
@WireVariable
private RequirementTypeService reqTypeService;
private List<Workgroup> centres; private List<Workgroup> centres;
private List<User> users; private List<User> users;
private List<User> passengers; private List<User> passengers;
@ -34,7 +37,7 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
@Init(superclass = true) @Init(superclass = true)
public void init() { public void init() {
centres = workgroupService.getUserCentres(userService.getCurrent()); centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
users = userService.getAll(); users = userService.getAll();
passengers = getDataBean().getPassengers(); passengers = getDataBean().getPassengers();
validator = new TripRequirementFormValidator(); validator = new TripRequirementFormValidator();

Loading…
Cancel
Save