Skip to content

Commit

Permalink
SAK-41058: lombok
Browse files Browse the repository at this point in the history
  • Loading branch information
bjones86 authored and ern committed Dec 18, 2018
1 parent adc13f1 commit a12018a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7041,7 +7041,7 @@ private void setNewAssignmentParameters(RunData data, boolean validify) {
if (thisCatRef != -1) {
for(CategoryDefinition thisCategoryDefinition : categoryDefinitions) {
if (Objects.equals(thisCategoryDefinition.getId(), thisCatRef)) {
if (thisCategoryDefinition.getIsDropped()) {
if (thisCategoryDefinition.getDropKeepEnabled()) {
Double thisCategoryPoints = thisCategoryDefinition.getPointsForCategory();
if (thisCategoryPoints != null) {
droppedCategoryPoints = thisCategoryPoints;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.util.Comparator;
import java.util.List;

import lombok.Getter;
import lombok.Setter;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

Expand All @@ -33,19 +36,19 @@ public class CategoryDefinition implements Serializable {

private static final long serialVersionUID = 1L;

private Long id;
private String name;
private Double weight;
private Integer dropLowest;
private Integer dropHighest;
private Integer keepHighest;
private Boolean extraCredit;
private Integer categoryOrder;
private Boolean isDropped;
@Getter @Setter private Long id;
@Getter @Setter private String name;
@Getter @Setter private Double weight;
@Getter @Setter private Integer dropLowest;
@Getter @Setter private Integer dropHighest;
@Getter @Setter private Integer keepHighest;
@Getter @Setter private Boolean extraCredit;
@Getter @Setter private Integer categoryOrder;
@Getter @Setter private Boolean dropKeepEnabled;

public static Comparator<CategoryDefinition> orderComparator;

private List<Assignment> assignmentList;
@Getter @Setter private List<Assignment> assignmentList;

public CategoryDefinition() {

Expand All @@ -55,118 +58,6 @@ public CategoryDefinition(Long id, String name) {
this.id = id;
this.name = name;
}

/**
*
* @return the id of the Category object
*/
public Long getId()
{
return id;
}

/**
*
* @param id the id of the Category object
*/
public void setId(Long id)
{
this.id = id;
}

/**
*
* @return the category name
*/
public String getName()
{
return name;
}

/**
*
* @param name the category name
*/
public void setName(String name)
{
this.name = name;
}

/**
*
* @return the weight set for this category if part of a weighted gradebook.
* null if gradebook is not weighted
*/
public Double getWeight()
{
return weight;
}

/**
* the weight set for this category if part of a weighted gradebook.
* null if gradebook is not weighted
* @param weight
*/
public void setWeight(Double weight)
{
this.weight = weight;
}

/**
* Get the list of Assignments associated with this category
* @return
*/
public List<Assignment> getAssignmentList() {
return assignmentList;
}

/**
* Set the list of Assignments for this category
* @return
*/
public void setAssignmentList(List<Assignment> assignmentList) {
this.assignmentList = assignmentList;
}

public Integer getDropLowest() {
return dropLowest;
}

public void setDropLowest(Integer dropLowest) {
this.dropLowest = dropLowest;
}

public Integer getDropHighest() {
return dropHighest;
}

public void setDropHighest(Integer dropHighest) {
this.dropHighest = dropHighest;
}

public Integer getKeepHighest() {
return keepHighest;
}

public void setKeepHighest(Integer keepHighest) {
this.keepHighest = keepHighest;
}

public Boolean isExtraCredit() {
return extraCredit;
}

public void setExtraCredit(Boolean extraCredit) {
this.extraCredit = extraCredit;
}

public Integer getCategoryOrder() {
return categoryOrder;
}

public void setCategoryOrder(Integer categoryOrder) {
this.categoryOrder = categoryOrder;
}

@Override
public String toString() {
Expand Down Expand Up @@ -207,19 +98,12 @@ public Double getTotalPoints() {
return totalPoints.doubleValue();
}

public Boolean getIsDropped() {
return isDropped;
}

public void setIsDropped(Boolean isDropped) {
this.isDropped = isDropped;
}

public boolean isAssignmentInThisCategory(String assignmentId) {
for (Assignment thisAssignment : this.assignmentList) {
for (Assignment thisAssignment : assignmentList) {
if (thisAssignment.getExternalId() == null) {
continue;
}

if (thisAssignment.getExternalId().equalsIgnoreCase(assignmentId)) {
return true;
}
Expand All @@ -229,11 +113,11 @@ public boolean isAssignmentInThisCategory(String assignmentId) {
}

public Double getPointsForCategory() {
if (!this.isDropped) {
if (!dropKeepEnabled) {
return null;
}

for (Assignment thisAssignment : this.assignmentList) {
for (Assignment thisAssignment : assignmentList) {
return thisAssignment.getPoints();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public Map<String,String> transferGradebook(final GradebookInformation gradebook
Long categoryId = null;
try {
categoryId = createCategory(gradebook.getId(), c.getName(), c.getWeight(), c.getDropLowest(),
c.getDropHighest(), c.getKeepHighest(), c.isExtraCredit(), c.getCategoryOrder());
c.getDropHighest(), c.getKeepHighest(), c.getExtraCredit(), c.getCategoryOrder());
} catch (final ConflictingCategoryNameException e) {
// category already exists. Could be from a merge.
log.info("Category: {} already exists in target site. Skipping creation.", c.getName());
Expand Down Expand Up @@ -506,7 +506,7 @@ public Map<String,String> transferGradebook(final GradebookInformation gradebook
categories.forEach(c -> {
try {
createCategory(gradebook.getId(), c.getName(), c.getWeight(), c.getDropLowest(), c.getDropHighest(), c.getKeepHighest(),
c.isExtraCredit(), c.getCategoryOrder());
c.getExtraCredit(), c.getCategoryOrder());
} catch (final ConflictingCategoryNameException e) {
// category already exists. Could be from a merge.
log.info("Category: {} already exists in target site. Skipping creation.", c.getName());
Expand Down Expand Up @@ -2502,7 +2502,7 @@ private CategoryDefinition getCategoryDefinition(final Category category) {
categoryDef.setDropHighest(category.getDropHighest());
categoryDef.setKeepHighest(category.getKeepHighest());
categoryDef.setAssignmentList(getAssignments(category.getGradebook().getUid(), category.getName()));
categoryDef.setIsDropped(category.isDropScores());
categoryDef.setDropKeepEnabled(category.isDropScores());
categoryDef.setExtraCredit(category.isExtraCredit());
categoryDef.setCategoryOrder(category.getCategoryOrder());
}
Expand Down Expand Up @@ -3344,7 +3344,7 @@ public void updateGradebookSettings(final String gradebookUid, final GradebookIn
existing.setDropLowest(newDef.getDropLowest());
existing.setDropHighest(newDef.getDropHighest());
existing.setKeepHighest(newDef.getKeepHighest());
existing.setExtraCredit(newDef.isExtraCredit());
existing.setExtraCredit(newDef.getExtraCredit());
existing.setCategoryOrder(categoryIndex);
updateCategory(existing);

Expand All @@ -3366,7 +3366,7 @@ public void updateGradebookSettings(final String gradebookUid, final GradebookIn
for (final Entry<CategoryDefinition, Integer> entry : newCategories.entrySet()) {
final CategoryDefinition newCat = entry.getKey();
this.createCategory(gradebook.getId(), newCat.getName(), newCat.getWeight(), newCat.getDropLowest(),
newCat.getDropHighest(), newCat.getKeepHighest(), newCat.isExtraCredit(), entry.getValue());
newCat.getDropHighest(), newCat.getKeepHighest(), newCat.getExtraCredit(), entry.getValue());
}

// if weighted categories, all uncategorised assignments are to be removed from course grade calcs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ private List<ColumnDefinition> loadColumns(final List<Assignment> assignments) {
.getString(),
nullable(categoryWeight),
category.getTotalPoints(),
category.isExtraCredit(),
category.getExtraCredit(),
userSettings.getCategoryColor(category.getName(), category.getId()),
!this.uiSettings.isCategoryScoreVisible(category.getName()),
FormatHelper.formatCategoryDropInfo(category)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void onValidate() {
error(getString("settingspage.update.failure.categorymissingweight"));
} else {
// extra credit items do not participate in the weightings, so exclude from the tally
if (!cat.isExtraCredit()) {
if (!cat.getExtraCredit()) {
totalWeight = totalWeight.add(BigDecimal.valueOf(cat.getWeight()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ protected void onUpdate(final AjaxRequestTarget target) {
// checkbox
final CategoryDefinition category = categoryMap.get(selected);

if (category != null && category.isExtraCredit()) {
if (category != null && category.getExtraCredit()) {
extraCredit.setModelObject(false);
extraCredit.setEnabled(false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ private void updateRunningTotal(final Component runningTotal, final Component ru
weight = BigDecimal.ZERO;
}

if (!categoryDefinition.isExtraCredit()) {
if (!categoryDefinition.getExtraCredit()) {
total = total.add(weight);
}
}
Expand Down

0 comments on commit a12018a

Please sign in to comment.