diff --git a/JavaSource/org/unitime/timetable/action/DistributionPrefsAction.java b/JavaSource/org/unitime/timetable/action/DistributionPrefsAction.java index fbf4d56d7f..26ff11fd27 100644 --- a/JavaSource/org/unitime/timetable/action/DistributionPrefsAction.java +++ b/JavaSource/org/unitime/timetable/action/DistributionPrefsAction.java @@ -647,14 +647,16 @@ private void doAddOrUpdate() throws Exception { dp.setDistributionObjects(s); oldOwner = (Department)dp.getOwner(); } - } else dp = new DistributionPref(); + } else { + dp = new DistributionPref(); + } dp.setDistributionType(DistributionTypeDAO.getInstance().get( Long.valueOf(form.getDistType()), hibSession)); dp.setStructure(form.getStructure()); dp.setPrefLevel(PreferenceLevel.getPreferenceLevel( Integer.parseInt(form.getPrefLevel()) )); - + Department owningDept = null; - + List distributionObjects = new ArrayList(); // Create distribution objects for (int i=0; i=0) - dp.setPrefLevel(PreferenceLevel.getPreferenceLevel(PreferenceLevel.sStronglyPreferred)); - else - throw new Exception("Creation of such constraint denied: unable to create "+dp.getPrefLevel().getPrefName()+" constraint owned by "+dp.getOwner()+"."); - } - if (dp.getPrefLevel().getPrefProlog().equals(PreferenceLevel.sProhibited)) { - if (dp.getDistributionType().getAllowedPref().indexOf(PreferenceLevel.sCharLevelStronglyDiscouraged)>=0) - dp.setPrefLevel(PreferenceLevel.getPreferenceLevel(PreferenceLevel.sStronglyDiscouraged)); - else - throw new Exception("Creation of such constraint denied: unable to create "+dp.getPrefLevel().getPrefName()+" constraint owned by "+dp.getOwner()+"."); - } - } - }*/ + for (DistributionObject dObj: distributionObjects) { + dObj.setDistributionPref(dp); + dp.addToDistributionObjects(dObj); + hibSession.persist(dObj); + } sessionContext.checkPermission(dp, Right.DistributionPreferenceEdit); // Save - if (dp.getUniqueId() == null) - hibSession.persist(dp); - else - hibSession.merge(dp); + hibSession.merge(dp); Permission permissionOfferingLockNeeded = getPermission("permissionOfferingLockNeeded");