Skip to content

Commit

Permalink
Removing date pickers
Browse files Browse the repository at this point in the history
More code review commits

Some codacy fixes
  • Loading branch information
jonespm committed Aug 8, 2019
1 parent 5fe2a41 commit 980f3b0
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 62 deletions.
8 changes: 0 additions & 8 deletions site/term-manager/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@

<dependencies>

<!-- project dependencies -->

<!-- third party dependencies -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<!-- Sakai dependencies -->
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sakaiproject.acadtermmanage;

public final class Constants {
public final class AcademicTermConstants {

// defined by Sakai:
public static final String PROP_NAME_TERM_EID="term_eid";
Expand All @@ -22,7 +22,7 @@ public final class Constants {
// TODO look at the course management API if it already defines a prefix for its AcademicSessions
public static final String EVENTSERVICE_EVENT_RESOURCE_PREFIX= "/academicsession/";

private Constants() {
private AcademicTermConstants() {
// don't want anybody to instantiate this class because it's just supposed to be a collection of constants
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;
import org.sakaiproject.acadtermmanage.Constants;
import org.sakaiproject.acadtermmanage.AcademicTermConstants;
import org.sakaiproject.acadtermmanage.exceptions.DuplicateKeyException;
import org.sakaiproject.acadtermmanage.exceptions.NoSuchKeyException;
import org.sakaiproject.acadtermmanage.logic.AcademicSessionLogic;
Expand Down Expand Up @@ -342,12 +342,12 @@ private boolean updateAllSites(String oldEID, String newEID, String newTitle) {
and opted for possibly data loss instead of making the SiteService throw an Exception
similar to a LazyInstantiationException ?? ) */
ResourcePropertiesEdit props = s.getPropertiesEdit();
String eid = props.getProperty(Constants.PROP_NAME_TERM_EID);
String eid = props.getProperty(AcademicTermConstants.PROP_NAME_TERM_EID);
log.debug("site's term eid: {}", eid);
if (oldEID.equals(eid)) {
log.debug("updating site properties for {}", siteID);
props.addProperty(Constants.PROP_NAME_TERM_EID, newEID);
props.addProperty(Constants.PROP_NAME_TERM_TITLE, newTitle);
props.addProperty(AcademicTermConstants.PROP_NAME_TERM_EID, newEID);
props.addProperty(AcademicTermConstants.PROP_NAME_TERM_TITLE, newTitle);

boolean success = true;
try {
Expand Down Expand Up @@ -395,7 +395,7 @@ public void updateSemester(String oldEID, Semester newValues) throws NoSuchKeyEx


// update cache
if (oldData != newValues) {
if (!oldData.equals(newValues)) {
log.debug("updating the cached Semester instance with new values");
// it might be a bit safer to use the "newValues" object itself, but in theory
// it should be enough to copy over the values to update the caches..
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sakaiproject.acadtermmanage.logic.impl;

import static org.sakaiproject.acadtermmanage.Constants.*;
import static org.sakaiproject.acadtermmanage.AcademicTermConstants.*;

import java.util.Date;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sakaiproject.acadtermmanage.tool;

public interface Constants {
public interface AcademicTermConstants {
public static final String PROP_EID="eid";
public static final String PROP_START="startDate";
public static final String PROP_END="endDate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ <h3 class="panel-title">
<div class="form-group">
<label class="control-label col-xs-3" wicket:for="startDate"><wicket:message key="lbl_startDate" />: </label>
<div class="col-xs-9">

<span class="sakai.acadtermmanage-datepicker" wicket:id="startDate" />
<input class="form-control" type="text" wicket:id="startDate" />
</div>

</div>
<div class="form-group">
<label class="control-label col-xs-3" wicket:for="endDate"><wicket:message key="lbl_endDate" />: </label>
<div class="col-xs-9">
<span class="sakai.acadtermmanage-datepicker" wicket:id="endDate" />
<input class="form-control" type="text" wicket:id="endDate" />
</div>
</div>
<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.extensions.yui.calendar.DateField;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.CheckBox;
Expand All @@ -30,16 +29,15 @@
import org.sakaiproject.acadtermmanage.exceptions.DuplicateKeyException;
import org.sakaiproject.acadtermmanage.exceptions.NoSuchKeyException;
import org.sakaiproject.acadtermmanage.model.Semester;
import org.sakaiproject.acadtermmanage.tool.Constants;
import org.sakaiproject.acadtermmanage.tool.AcademicTermConstants;
import org.sakaiproject.acadtermmanage.tool.util.ComparatorFactory;
import org.sakaiproject.acadtermmanage.tool.util.ReversableComparator;
import org.sakaiproject.acadtermmanage.tool.wicketstuff.ActionLink;
import org.sakaiproject.acadtermmanage.tool.wicketstuff.ActionPanel;

import lombok.extern.slf4j.Slf4j;
// TODO fromDate must not be after startDate => validator
@Slf4j
public class SemesterPage extends BasePage implements Constants{
public class SemesterPage extends BasePage implements AcademicTermConstants{

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -140,8 +138,8 @@ public SemesterForm(String id, Semester sem) {
super(id, new CompoundPropertyModel<Semester>(sem));
add(new RequiredTextField<String>(PROP_EID));
add(new TextField<String>(PROP_TITLE));
add(new DateField(PROP_START));
add(new DateField(PROP_END));
add(new TextField(PROP_START));
add(new TextField(PROP_END));
add(new TextField<String>(PROP_DESC){

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -327,10 +325,10 @@ public Iterator<? extends Semester> iterator(long first, long count) {
String prop = getSort().getProperty();
SortOrder order = getSortState().getPropertySortOrder(prop);
Comparator<Semester> comp = ComparatorFactory.createComparator(prop);
if (order == SortOrder.DESCENDING) {
comp = new ReversableComparator<Semester>(comp, true);
}
Collections.sort(myList, comp);
if (order == SortOrder.DESCENDING) {
Collections.reverse(myList);
}
needToSortList = false;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Date;

import org.sakaiproject.acadtermmanage.model.Semester;
import org.sakaiproject.acadtermmanage.tool.Constants;
import org.sakaiproject.acadtermmanage.tool.AcademicTermConstants;

import lombok.extern.slf4j.Slf4j;

Expand All @@ -14,11 +14,11 @@
*
*/
@Slf4j
public class ComparatorFactory implements Constants {
public class ComparatorFactory implements AcademicTermConstants {


public static final <T extends Comparable<T>> int compare(T o1,T o2) {
if (o1==o2) { // catches both objects being null - among other things
if (o1.equals(o2)) { // catches both objects being null - among other things
return 0;
}
else if (o1 != null) {
Expand Down

This file was deleted.

0 comments on commit 980f3b0

Please sign in to comment.