/** * This cover is for the benefit of JSF checkboxes. */ public void setCounted(final boolean counted) { setNotCounted(!counted); }
private GradebookAssignment prepareNewAssignment(String name, Double points, Date dueDate, Boolean isNotCounted, Boolean isReleased, Boolean isExtraCredit) { String validatedName = StringUtils.trimToNull(name); if (validatedName == null){ throw new ConflictingAssignmentNameException("You cannot save an assignment without a name"); } // name cannot contain these special chars as they are reserved for special columns in import/export GradebookHelper.validateGradeItemName(validatedName); GradebookAssignment asn = new GradebookAssignment(); asn.setName(validatedName); asn.setPointsPossible(points); asn.setDueDate(dueDate); asn.setUngraded(false); if (isNotCounted != null) { asn.setNotCounted(isNotCounted.booleanValue()); } if (isExtraCredit != null) { asn.setExtraCredit(isExtraCredit.booleanValue()); } if (isReleased != null) { asn.setReleased(isReleased.booleanValue()); } return asn; }
if (isNotCounted != null) asn.setNotCounted(isNotCounted.booleanValue());
public Long createUngradedAssignment(final Long gradebookId, final String name, final Date dueDate, final Boolean isNotCounted, final Boolean isReleased) throws ConflictingAssignmentNameException, StaleObjectModificationException { final HibernateCallback<Long> hc = session -> { final Gradebook gb = (Gradebook) session.load(Gradebook.class, gradebookId); // trim the name before validation final String trimmedName = StringUtils.trimToEmpty(name); if(assignmentNameExists(trimmedName, gb)) { throw new ConflictingAssignmentNameException("You can not save multiple assignments in a gradebook with the same name"); } final GradebookAssignment asn = new GradebookAssignment(); asn.setGradebook(gb); asn.setName(trimmedName); asn.setDueDate(dueDate); asn.setUngraded(true); if (isNotCounted != null) { asn.setNotCounted(isNotCounted); } if (isReleased != null) { asn.setReleased(isReleased); } return (Long) session.save(asn); }; return getHibernateTemplate().execute(hc); }
public Long createUngradedAssignmentForCategory(final Long gradebookId, final Long categoryId, final String name, final Date dueDate, final Boolean isNotCounted, final Boolean isReleased) throws ConflictingAssignmentNameException, StaleObjectModificationException, IllegalArgumentException { if (gradebookId == null || categoryId == null) { throw new IllegalArgumentException("gradebookId or categoryId is null in BaseHibernateManager.createUngradedAssignmentForCategory"); } final HibernateCallback<Long> hc = session -> { final Gradebook gb = (Gradebook) session.load(Gradebook.class, gradebookId); final Category cat = (Category) session.load(Category.class, categoryId); // trim the name before the validation final String trimmedName = StringUtils.trimToEmpty(name); if (assignmentNameExists(trimmedName, gb)) { throw new ConflictingAssignmentNameException("You can not save multiple assignments in a gradebook with the same name"); } final GradebookAssignment asn = new GradebookAssignment(); asn.setGradebook(gb); asn.setCategory(cat); asn.setName(trimmedName); asn.setDueDate(dueDate); asn.setUngraded(true); if (isNotCounted != null) { asn.setNotCounted(isNotCounted); } if (isReleased != null) { asn.setReleased(isReleased); } return (Long) session.save(asn); }; return getHibernateTemplate().execute(hc); }
public Long createUngradedAssignment(final Long gradebookId, final String name, final Date dueDate, final Boolean isNotCounted, final Boolean isReleased) throws ConflictingAssignmentNameException, StaleObjectModificationException { HibernateCallback<Long> hc = session -> { Gradebook gb = (Gradebook) session.load(Gradebook.class, gradebookId); // trim the name before validation String trimmedName = StringUtils.trimToEmpty(name); if(assignmentNameExists(trimmedName, gb)) { throw new ConflictingAssignmentNameException("You can not save multiple assignments in a gradebook with the same name"); } GradebookAssignment asn = new GradebookAssignment(); asn.setGradebook(gb); asn.setName(trimmedName); asn.setDueDate(dueDate); asn.setUngraded(true); if (isNotCounted != null) { asn.setNotCounted(isNotCounted); } if (isReleased != null) { asn.setReleased(isReleased); } return (Long) session.save(asn); }; return getHibernateTemplate().execute(hc); }
public Long createUngradedAssignmentForCategory(final Long gradebookId, final Long categoryId, final String name, final Date dueDate, final Boolean isNotCounted, final Boolean isReleased) throws ConflictingAssignmentNameException, StaleObjectModificationException, IllegalArgumentException { if (gradebookId == null || categoryId == null) { throw new IllegalArgumentException("gradebookId or categoryId is null in BaseHibernateManager.createUngradedAssignmentForCategory"); } HibernateCallback<Long> hc = session -> { Gradebook gb = (Gradebook) session.load(Gradebook.class, gradebookId); Category cat = (Category) session.load(Category.class, categoryId); // trim the name before the validation String trimmedName = StringUtils.trimToEmpty(name); if (assignmentNameExists(trimmedName, gb)) { throw new ConflictingAssignmentNameException("You can not save multiple assignments in a gradebook with the same name"); } GradebookAssignment asn = new GradebookAssignment(); asn.setGradebook(gb); asn.setCategory(cat); asn.setName(trimmedName); asn.setDueDate(dueDate); asn.setUngraded(true); if (isNotCounted != null) { asn.setNotCounted(isNotCounted); } if (isReleased != null) { asn.setReleased(isReleased); } return (Long) session.save(asn); }; return getHibernateTemplate().execute(hc); }