diff --git a/api/pom.xml b/api/pom.xml
index 16a6776a..8ffd15a9 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -20,7 +20,7 @@
attendance
org.sakaiproject.attendance
- 23-SNAPSHOT
+ 25-SNAPSHOT
attendance - API
@@ -45,8 +45,8 @@
hibernate-core
- commons-lang
- commons-lang
+ org.apache.commons
+ commons-lang3
diff --git a/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java b/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java
index b6daee30..0536b65d 100644
--- a/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java
+++ b/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java
@@ -18,9 +18,8 @@
import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Created by james on 7/11/17.
@@ -29,49 +28,11 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
+@EqualsAndHashCode
public class AttendanceUserGroupStats {
private static final long serialVersionUID = 1L;
private String userID;
private String groupId;
private AttendanceSite attendanceSite;
-
-
- public AttendanceUserGroupStats(String userID, AttendanceSite attendanceSite) {
- this.userID = userID;
- this.attendanceSite = attendanceSite;
- }
-
- @Override
- public boolean equals (final Object obj) {
- if(obj == null) {
- return false;
- }
-
- if(obj == this) {
- return true;
- }
-
- if(obj.getClass() != getClass()) {
- return false;
- }
-
- final AttendanceUserGroupStats other = (AttendanceUserGroupStats) obj;
- return new EqualsBuilder()
- .appendSuper(super.equals(obj))
- .append(this.userID, other.userID)
- .append(this.groupId, other.groupId)
- .append(this.attendanceSite, other.attendanceSite)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder()
- .appendSuper(super.hashCode())
- .append(this.userID)
- .append(this.groupId)
- .append(this.attendanceSite.getId())
- .toHashCode();
- }
}
diff --git a/impl/pom.xml b/impl/pom.xml
index 5b281a71..51f99c02 100644
--- a/impl/pom.xml
+++ b/impl/pom.xml
@@ -20,7 +20,7 @@
attendance
org.sakaiproject.attendance
- 23-SNAPSHOT
+ 25-SNAPSHOT
attendance - Implementation
@@ -58,12 +58,12 @@
ehcache-core
- commons-lang
- commons-lang
+ org.apache.commons
+ commons-lang3
- commons-configuration
- commons-configuration
+ org.apache.commons
+ commons-configuration2
org.hibernate
diff --git a/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java b/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java
index 7a5a8ee2..4776af7f 100644
--- a/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java
+++ b/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java
@@ -28,7 +28,6 @@
import org.sakaiproject.grading.api.CategoryDefinition;
import org.sakaiproject.grading.api.ConflictingAssignmentNameException;
import org.sakaiproject.grading.api.GradingService;
-import org.sakaiproject.tool.api.Tool;
import org.sakaiproject.tool.api.ToolManager;
import java.util.HashMap;
diff --git a/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java b/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java
index 934998a0..8f3842e3 100644
--- a/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java
+++ b/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java
@@ -20,24 +20,18 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.authz.api.*;
import org.sakaiproject.component.api.ServerConfigurationService;
-import org.sakaiproject.entity.api.ResourceProperties;
-import org.sakaiproject.entity.api.ResourcePropertiesEdit;
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.site.api.Group;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.api.SiteService;
-import org.sakaiproject.time.api.Time;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.SessionManager;
import org.sakaiproject.tool.api.ToolManager;
import org.sakaiproject.user.api.*;
-import org.sakaiproject.util.ResourceLoader;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import java.util.*;
@@ -66,7 +60,6 @@ public String getCurrentSiteTitle() {
return siteService.getSite(getCurrentSiteId()).getTitle();
} catch (IdUnusedException e) {
log.error("getCurrentSiteTitle()", e);
- e.printStackTrace();
return "";
}
}
@@ -242,7 +235,6 @@ public List getAvailableGroupsForSite(String siteId) {
return returnList;
} catch (IdUnusedException e) {
log.error("getAvailableGroupIdsForSite " + siteId + " IdUnusedException");
- e.printStackTrace();
return new ArrayList();
}
}
@@ -262,7 +254,6 @@ public User getUser(String userId) {
return userDirectoryService.getUser(userId);
} catch (UserNotDefinedException e) {
log.error("Unable to get user " + userId + " " + e);
- e.printStackTrace();
return null;
}
}
@@ -275,7 +266,6 @@ public final User getUserByEID(String userEid) {
return userDirectoryService.getUserByEid(userEid);
} catch (UserNotDefinedException e) {
log.error("Unable to get user " + userEid + " " + e);
- e.printStackTrace();
return null;
}
}
@@ -333,7 +323,6 @@ public String getGroupTitle(String siteId, String groupId) {
}
} catch (IdUnusedException e) {
log.error("Unable to get group title", e);
- e.printStackTrace();
}
return "";
}
diff --git a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java
index 021ffd79..d4ebc00d 100644
--- a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java
+++ b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java
@@ -54,7 +54,7 @@ public void execute() {
if("".equals(summary)) {
log.info("AttendanceStatCalc no sites left to sync");
} else {
- log.info("AttendanceStatCalc done, but there are errors\n" + summary);
+ log.info("AttendanceStatCalc done, but there are errors\n{}", summary);
}
} else {
while(!ids.isEmpty()) {
@@ -63,10 +63,10 @@ public void execute() {
calculateStats(id);
lastId = id > lastId ? id : lastId++; // never-ending loop protection
}
- log.info("AttendanceStatCalc in progress " + getSummary());
+ log.info("AttendanceStatCalc in progress {}", getSummary());
ids = dao.getAttendanceSiteBatch(syncTime, lastId);
}
- log.info("AttendanceStatCalc finished " + getSummary());
+ log.info("AttendanceStatCalc finished {}", getSummary());
log.info(getOverallSummary());
}
@@ -105,22 +105,21 @@ private void calculateStats(Long id) {
}
} else {
sitesWithNoUsers++;
- log.debug("AttendanceSite, id: '" + id +"' has no users or Site, id: '"
- + attendanceSite.getSiteID() +"' no longer exists.");
+ log.debug("AttendanceSite, id: '{}' has no users or Site, id: '{}' no longer exists.", id, attendanceSite.getSiteID());
}
attendanceSite.setIsSyncing(false);
attendanceLogic.updateAttendanceSite(attendanceSite);
- log.debug("AttendanceSite synced with id: " + id);
+ log.debug("AttendanceSite synced with id: {}", id);
sitesProcessed++;
} else {
- log.debug("AttendanceSite not marked as in progress" + id);
+ log.debug("AttendanceSite not marked as in progress{}", id);
sitesNotMarked++;
}
} catch (Exception e) {
sitesInError++;
- log.warn("Error syncing AttendanceSite id: " + id, e);
+ log.warn("Error syncing AttendanceSite id: {}", id, e);
}
}
@@ -154,8 +153,7 @@ private void calculateEventStats(AttendanceEvent event, Map userS
userStats.put(record.getUserID(), array);
} else {
- log.debug("AttendanceRecord user no longer present in course, record id: '" + record.getId()
- + "' and userID: " + record.getUserID());
+ log.debug("AttendanceRecord user no longer present in course, record id: '{}' and userID: {}", record.getId(), record.getUserID());
}
}
@@ -177,7 +175,7 @@ private String getSummary() {
private String getOverallSummary() {
List inProgress = dao.getAttendanceSitesInSync();
- if(inProgress.size() > 0) {
+ if(!inProgress.isEmpty()) {
String message = "%d AttendanceSite(s) currently marked in sync. IDs marked in sync: %s";
return String.format(message, inProgress.size(), inProgress);
}
diff --git a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java
index 6b42e3f0..484168a8 100644
--- a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java
+++ b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java
@@ -87,7 +87,7 @@ public void execute(JobExecutionContext context) {
eventTrackingService.post(eventTrackingService.newEvent("attend.calc.job", safeEventLength(whoAmI.toString()), true));
- log.info("Start Job: " + whoAmI.toString());
+ log.info("Start Job: {}", whoAmI);
attendanceStatCalc.execute();
logoutFromSakai();
@@ -95,7 +95,7 @@ public void execute(JobExecutionContext context) {
}
public void loginToSakai(String whoAs, String jobName, String jobError) {
- log.debug(jobName + " loginToSakai()");
+ log.debug("{} loginToSakai()", jobName);
UsageSession session = usageSessionService.startSession(whoAs, serverName, jobName);
if (session == null) {
@@ -115,7 +115,7 @@ public void loginToSakai(String whoAs, String jobName, String jobError) {
}
public void logoutFromSakai() {
- log.debug(jobName + " Logging out of Sakai on " + serverName);
+ log.debug(jobName + " Logging out of Sakai on {}", serverName);
eventTrackingService.post(eventTrackingService.newEvent(UsageSessionService.EVENT_LOGOUT, null, true));
usageSessionService.logout(); // safe to logout? what if other jobs are running?
}
diff --git a/pom.xml b/pom.xml
index 54c5cc4d..9239e411 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
org.sakaiproject
master
- 23-SNAPSHOT
+ 25-SNAPSHOT
@@ -78,28 +78,23 @@
org.apache.wicket
wicket
- 6.21.0
- pom
+ 9.17.0
+ pom
org.apache.wicket
wicket-spring
- 6.21.0
-
-
- org.apache.wicket
- wicket-datetime
- 6.21.0
-
+ 9.17.0
+
org.apache.wicket
wicket-extensions
- 6.21.0
+ 9.17.0
- commons-configuration
- commons-configuration
- 1.10
+ org.apache.commons
+ commons-configuration2
+ ${sakai.commons.configuration2.version}
commons-logging
diff --git a/tool/pom.xml b/tool/pom.xml
index d4f06826..59978af3 100644
--- a/tool/pom.xml
+++ b/tool/pom.xml
@@ -22,7 +22,7 @@
attendance
org.sakaiproject.attendance
- 23-SNAPSHOT
+ 25-SNAPSHOT
attendance - Tool
@@ -58,16 +58,6 @@
-
- org.apache.wicket
- wicket-datetime
-
-
-
- joda-time
- joda-time
- ${joda.time.version}
-
org.apache.wicket
wicket-extensions
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java b/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java
index 03da68a8..f25611ea 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java
@@ -45,7 +45,10 @@ public class Attendance extends WebApplication {
protected void init() {
super.init();
- //Configure for Spring injection
+ // Disable the CSP header (we can handle this in root of application)
+ getCspSettings().blocking().disabled();
+
+ //Configure for Spring injection
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
//Don't throw an exception if we are missing a property, just fallback
@@ -53,10 +56,6 @@ protected void init() {
//Remove the wicket specific tags from the generated markup
getMarkupSettings().setStripWicketTags(true);
-
- //Don't add any extra tags around a disabled link (default is )
- getMarkupSettings().setDefaultBeforeDisabledLink(null);
- getMarkupSettings().setDefaultAfterDisabledLink(null);
// On Wicket session timeout, redirect to main page
getApplicationSettings().setPageExpiredErrorPage(Overview.class);
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java b/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java
index 8b50dcad..e149631a 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java
@@ -17,7 +17,6 @@
package org.sakaiproject.attendance.tool.dataproviders;
import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
import org.sakaiproject.attendance.tool.models.DetachableUserModel;
import org.sakaiproject.user.api.User;
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java b/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java
index a04b3baa..03d8d58f 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java
@@ -11,6 +11,7 @@ public ProfileImage(String id, IModel urlModel)
super( id, urlModel );
}
+ @Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag( tag );
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html
index d5ce7e43..38033032 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html
@@ -36,13 +36,13 @@
-
+
-
-
-
+
+
+
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java
index ed7bfa77..e210e73b 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java
@@ -1,23 +1,22 @@
package org.sakaiproject.attendance.tool.pages;
import org.apache.commons.codec.binary.StringUtils;
-import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
-import org.apache.wicket.extensions.yui.calendar.DateTimeField;
+import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.*;
import org.sakaiproject.attendance.model.AttendanceEvent;
-import org.sakaiproject.attendance.tool.pages.EventView;
-import org.sakaiproject.attendance.tool.pages.Overview;
import org.sakaiproject.attendance.tool.util.AttendanceFeedbackPanel;
-import org.sakaiproject.attendance.tool.util.ConfirmationLink;
import org.sakaiproject.attendance.tool.util.PlaceholderBehavior;
+import java.util.Date;
+
+
public class EventInputPage extends BasePage{
private static final long serialVersionUID = 1L;
private IModel eventModel;
@@ -54,7 +53,7 @@ private Form createEventInputForm() {
private static final long serialVersionUID = 1L;
@Override
- public void onSubmit(final AjaxRequestTarget target, final Form> form) {
+ public void onSubmit(final AjaxRequestTarget target) {
// decide where to go based on where we came from.
String nextPage = EventInputPage.this.getNextPage();
if(StringUtils.equals(nextPage, EventInputPage.GRADING)) {
@@ -72,18 +71,16 @@ public void onSubmit(final AjaxRequestTarget target, final Form> form) {
};
cancel.setDefaultFormProcessing(false);
eventForm.add(cancel);
- final TextField name = new TextField("name") {
- @Override
- protected void onInitialize(){
- super.onInitialize();
- add(new PlaceholderBehavior(getString("event.placeholder.name")));
- }
- };
- final DateTimeField startDateTime = new DateTimeField("startDateTime");
+ final TextField name = new TextField<>("name");
name.setRequired(true);
+ name.add(new PlaceholderBehavior(getString("event.placeholder.name")));
+
+ final DateTextField startDateTime = new DateTextField("startDateTime", null, "yyyy-MM-dd'T'HH:mm");
+
eventForm.add(name);
eventForm.add(startDateTime);
return eventForm;
+
}
private void processSave(AjaxRequestTarget target, Form> form, boolean addAnother) {
@@ -91,7 +88,8 @@ private void processSave(AjaxRequestTarget target, Form> form, boolean addAnot
e.setAttendanceSite(attendanceLogic.getCurrentAttendanceSite());
boolean result = attendanceLogic.updateAttendanceEvent(e);
if(result){
- StringResourceModel temp = new StringResourceModel("attendance.add.success", null, new String[]{e.getName()});
+ StringResourceModel temp = new StringResourceModel("attendance.add.success", this);
+ temp.setParameters(e.getName());
getSession().success(temp.getString());
} else {
error(getString("attendance.add.failure"));
@@ -107,8 +105,8 @@ private void processSave(AjaxRequestTarget target, Form> form, boolean addAnot
private AjaxSubmitLink createSubmitLink(final String id, final Form> form, final boolean createAnother) {
return new AjaxSubmitLink(id, form) {
@Override
- protected void onSubmit(AjaxRequestTarget target, Form> form) {
- super.onSubmit(target, form);
+ protected void onSubmit(AjaxRequestTarget target) {
+ super.onSubmit(target);
processSave(target, form, createAnother);
}
@@ -118,7 +116,7 @@ public boolean isEnabled() {
}
@Override
- protected void onError(AjaxRequestTarget target, Form> form) {
+ protected void onError(AjaxRequestTarget target) {
target.addChildren(form, FeedbackPanel.class);
}
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java
index a733d5a7..2b70ac54 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java
@@ -35,6 +35,7 @@
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy;
import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.ResourceModel;
@@ -157,7 +158,7 @@ public int compare(AttendanceStatus o1, AttendanceStatus o2) {
}
setAllForm.add(setAllStatus = new DropDownChoice<>("set-all-status", new Model<>(), activeStatuses, new EnumChoiceRenderer<>(this)));
- setAllStatus.add(new AjaxFormSubmitBehavior("onchange") {
+ setAllStatus.add(new AjaxFormSubmitBehavior("change") {
@Override
protected void onSubmit(AjaxRequestTarget target) {
super.onSubmit(target);
@@ -249,10 +250,20 @@ public Object getDisplayValue(String s) {
public String getIdValue(String s, int i) {
return s;
}
+
+ @Override
+ public String getObject(String s, IModel extends List extends String>> iModel) {
+ for (String groupId : groupIds) {
+ if (groupId.equals(s)) {
+ return s;
+ }
+ }
+ return null;
+ }
});
groupChoice.setNullValid(true);
- groupChoice.add(new AjaxFormSubmitBehavior("onchange") {
+ groupChoice.add(new AjaxFormSubmitBehavior("change") {
@Override
protected void onSubmit(AjaxRequestTarget target) {
super.onSubmit(target);
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html
index d3f11f2e..cdc74c56 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html
@@ -27,7 +27,7 @@
@@ -38,7 +38,7 @@
-
+
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java
index c099499e..27902fcc 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java
@@ -16,46 +16,43 @@
package org.sakaiproject.attendance.tool.pages;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Row;
import org.apache.wicket.model.StringResourceModel;
-import org.sakaiproject.component.cover.ServerConfigurationService;
-import org.sakaiproject.attendance.logic.SakaiProxy;
import org.sakaiproject.attendance.model.*;
+import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.user.api.User;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.lang.Bytes;
-import org.apache.wicket.util.time.Duration;
import org.apache.wicket.markup.html.link.DownloadLink;
import org.apache.wicket.markup.html.form.upload.FileUpload;
import org.apache.wicket.markup.html.form.upload.FileUploadField;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.ss.usermodel.CellType;
-
import java.io.*;
-
+import java.time.Duration;
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import lombok.extern.slf4j.Slf4j;
-
/**
* Created by james on 5/18/17.
@@ -113,7 +110,7 @@ protected File load() {
public void onSubmit() {
setResponsePage(new ExportPage());
}
- }).setCacheDuration(Duration.NONE).setDeleteAfterDownload(true));
+ }).setCacheDuration(Duration.ZERO).setDeleteAfterDownload(true));
add(new UploadForm("form"));
}
@@ -173,8 +170,8 @@ public int compare(AttendanceEvent attendanceEvent, AttendanceEvent t1) {
}
});
int columnGetter = 3; //separate counter for columns in case there are comments, in which case the following loop's counter will increment differently.
- for(int count=0; count rows = sheet.rowIterator();
if(rows.hasNext()){ //don't do anything with the Iterator unless it has something.
final List headerRow = processHeaderRow(rows);
List badIds = checkHeader(siteEventList, headerRow, errors);
- checkHeader = badIds.size()<1; //if there are bad IDs, the header is bad [checkHeader = false]
+ checkHeader = badIds.isEmpty(); //if there are bad IDs, the header is bad [checkHeader = false]
while(rows.hasNext()){
HSSFRow currentRow = (HSSFRow) rows.next();
commentsChanged = processOneDataRow(currentRow, usableIDs, headerRow, ICList, commentsChanged, errors);
@@ -361,7 +354,7 @@ private List processHeaderRow(Iterator rows){
private List checkHeader(List siteEventList, List headerRow, List errors){
List siteEventListIds = getActualEventIds(siteEventList);
List badIds = new ArrayList();
- for(int count = 3; count < headerRow.size() && headerRow.get(count).length()>0; count++){ //see if every ID in idTracker is in Attendance already
+ for(int count = 3; count < headerRow.size() && !headerRow.get(count).isEmpty(); count++){ //see if every ID in idTracker is in Attendance already
Long getIdResult = getIdFromString(headerRow.get(count), errors);
if(!siteEventListIds.contains(getIdResult)){ //if not, this header had bad IDs (events that Attendance doesn't have)
badIds.add(getIdResult); //add the bad ID into the array.
@@ -394,19 +387,20 @@ private List getActualEventIds (List siteEventList){
return usableIds;
}
- private void addErrorsToSession(List errors){
- for(int count = 0; count<4 && count0; count++){
+ private void addErrorsToSession(List errors) {
+ for (int count = 0; count < Math.min(4, errors.size()); count++) {
getSession().error(errors.get(count));
}
- if(errors.size()>4){
- String howManyErrors = "" + (errors.size()-4);
- getSession().error(new StringResourceModel("attendance.import.more.errors", null, new String[]{howManyErrors}).getString());
+
+ if (errors.size() > 4) {
+ String howManyErrors = String.valueOf(errors.size() - 4);
+ getSession().error(getString("attendance.import.more.errors", null, howManyErrors));
}
}
private boolean processOneDataRow(HSSFRow row, List usableIds, List headerRow, List ICList, boolean commentsChanged, List errors) {
AttendanceSite attendanceSite = attendanceLogic.getAttendanceSite(sakaiProxy.getCurrentSiteId());
- List data = new ArrayList(); // container for the current row's data
+ List data = new ArrayList<>(); // container for the current row's data
for (int countCells=0; countCells usableIds, List usableIds, List 0){ //add the newData comment to the ICL if it's not empty.
+ if(newData.getComment()!=null && !newData.getComment().isEmpty()){ //add the newData comment to the ICL if it's not empty.
ICL.setComment(newData.getComment());
}else{ //if it IS empty, just throw in the old comment.
ICL.setComment(checker.getComment());
@@ -485,12 +481,12 @@ private boolean processOneDataRow(HSSFRow row, List usableIds, List2){
- if(data.get(1).toString().length() > 0){
- errors.add(new StringResourceModel("attendance.import.fake.student", null, new String[]{data.get(1).toString()}).getString()); //when there's a fake student in Excel that isn't in Attendance
+ if(!data.get(1).isEmpty()){
+ errors.add(new StringResourceModel("attendance.import.fake.student", this, Model.of(data.get(1).toString())).getString());
}else{
errors.add(getString("attendance.import.blank.row")); //when there's a blank row in Excel that has no data
}
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java
index c79dd8b5..518b2d66 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java
@@ -22,14 +22,12 @@
import java.util.*;
import java.util.List;
-import org.apache.wicket.AttributeModifier;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;
-import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
@@ -45,8 +43,6 @@ public class ImportConfirmation extends BasePage{
protected void onBeforeRender() {
super.onBeforeRender();
disableLink(exportLink);
-
-
add(new ImportConfirmation.UploadForm("form"));
}
private static final long serialVersionUID = 1L;
@@ -58,16 +54,6 @@ protected void onBeforeRender() {
public ImportConfirmation(List attendanceItemDataList, Boolean commentsChanged) {
this.uploadICLList = attendanceItemDataList;
- homepageLink = new Link("homepage-link2") {
- private static final long serialVersionUID = 1L;
- public void onClick() {
-
- setResponsePage(new Overview());
- }
- };
- homepageLink.add(new Label("homepage-link-label",new ResourceModel("attendance.link.homepage")).setRenderBodyOnly(true));
- homepageLink.add(new AttributeModifier("title", new ResourceModel("attendance.link.homepage.tooltip")));
- add(homepageLink);
if(this.role != null && this.role.equals("Student")) {
throw new RestartResponseException(StudentView.class);
@@ -184,36 +170,44 @@ private String changeStatString(String stat){
}
private class UploadForm extends Form {
+ private Label lowerErrorAlert = new Label("lowerErrorAlert");
+ private SubmitLink completeImport = new SubmitLink("submitLink") {
+ @Override
+ public void onSubmit() {
+ uploadICLList.forEach(item -> {
+ attendanceLogic.updateAttendanceRecord(item.getAttendanceRecord(), item.getOldStatus());
+ attendanceLogic.updateAttendanceSite(item.getAttendanceSite());
+ });
+ success(getString("attendance.export.confirmation.import.save.success"));
+ setResponsePage(new Overview());
+ }
+ };
public UploadForm(final String id) {
super(id);
- SubmitLink completeImport = new SubmitLink("submitLink") {
- public void onSubmit() {
- for (int i = 0; i < uploadICLList.size(); i++){
- boolean updated = attendanceLogic.updateAttendanceRecord(uploadICLList.get(i).getAttendanceRecord(), uploadICLList.get(i).getOldStatus());
- attendanceLogic.updateAttendanceSite(uploadICLList.get(i).getAttendanceSite());
- }
- getSession().success(getString("attendance.export.confirmation.import.save.success"));
- setResponsePage(new Overview());
- }
- };
- Label lowerErrorAlert = new Label("lowerErrorAlert");
- if (!getSession().getFeedbackMessages().isEmpty()){
- completeImport.setEnabled(false);
- lowerErrorAlert = new Label("lowerErrorAlert", getString("attendance.import.errors.exist"));
- }
- if(uploadICLList.size()<1){
- getSession().error(getString("attendance.export.import.save.noChange"));
- completeImport.setEnabled(false);
- }
add(lowerErrorAlert);
add(completeImport);
add(new SubmitLink("submitLink2") {
+ @Override
public void onSubmit() {
setResponsePage(new ExportPage());
}
});
}
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ if (!getSession().getFeedbackMessages().isEmpty()) {
+ completeImport.setEnabled(false);
+ lowerErrorAlert.setDefaultModelObject(getString("attendance.import.errors.exist"));
+ }
+ if (uploadICLList != null && uploadICLList.isEmpty()) {
+ completeImport.setEnabled(false);
+ getSession().error(getString("attendance.export.import.save.noChange"));
+ }
+ }
}
}
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java
index b15b4bda..2d9bc827 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java
@@ -20,22 +20,15 @@
import org.apache.wicket.Page;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.ajax.markup.html.form.AjaxButton;
-import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.extensions.markup.html.form.select.Select;
-import org.apache.wicket.extensions.markup.html.form.select.SelectOption;
-import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.model.StringResourceModel;
import org.sakaiproject.attendance.model.AttendanceEvent;
@@ -44,11 +37,10 @@
import org.sakaiproject.attendance.model.Status;
import org.sakaiproject.attendance.tool.dataproviders.AttendanceStatusProvider;
import org.sakaiproject.attendance.tool.dataproviders.EventDataProvider;
-import org.sakaiproject.attendance.tool.panels.EventInputPanel;
import org.sakaiproject.attendance.tool.panels.PrintPanel;
import org.sakaiproject.attendance.tool.util.ConfirmationLink;
-import java.util.*;
+import java.util.Date;
/**
* The overview page which lists AttendanceEvents and basic statistics of each
@@ -101,8 +93,10 @@ private void createHeaders() {
String addButtonText = (new ResourceModel("attendance.add.button")).getObject();
String takeAttendanceNowText = (new ResourceModel("attendance.now.button")).getObject();
- Label headerInfo = new Label("overview-header-info", new StringResourceModel("attendance.overview.header.info",
- null, new Object[]{addButtonText, takeAttendanceNowText}));
+ Label headerInfo = new Label("overview-header-info",
+ new StringResourceModel("attendance.overview.header.info")
+ .setParameters(addButtonText, takeAttendanceNowText)
+ );
headerInfo.setEscapeModelStrings(false);
//headers for the table
@@ -232,22 +226,4 @@ protected void onSubmit() {
add(takeAttendanceNowForm);
}
- private void createAddAttendanceItem() {
- final Form> addAttendanceItemForm = new Form("add-attendance-item-form");
- final AjaxButton addAttendanceItem = new AjaxButton("add-attendance-item") {
- @Override
- public void onSubmit(final AjaxRequestTarget target, final Form form) {
- final ModalWindow window = getAddOrEditItemWindow();
- window.setTitle(new ResourceModel("attendance.add.header"));
- window.setContent(new EventInputPanel(window.getContentId(), window, null));
- window.show(target);
- }
- };
-
- addAttendanceItem.setDefaultFormProcessing(false);
- addAttendanceItem.setOutputMarkupId(true);
- addAttendanceItemForm.add(addAttendanceItem);
-
- add(addAttendanceItemForm);
- }
}
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html
index 1fe03ba9..99bf20f2 100644
--- a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html
+++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html
@@ -44,7 +44,7 @@