<commit_before>/**********************************************************************************
 * $URL: https://source.sakaiproject.org/contrib/signup/branches/2-6-x/tool/src/java/org/sakaiproject/signup/tool/jsf/SignupSorter.java $
 * $Id: SignupSorter.java 56827 2009-01-13 21:52:18Z <EMAIL> $
***********************************************************************************
 *
 * Copyright (c) 2007, 2008, 2009 Yale University
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *      http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 *   
 * See the LICENSE.txt distributed with this file.
 *
 **********************************************************************************/
package org.sakaiproject.signup.tool.jsf;

import java.text.Collator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

/**
 * *
 * <p>
 * This class will provide sorting logic for Sign-up tool main page.
 * </P>
 * 
 * @author gl256
 * 
 */
public class SignupSorter {

	public static final String TITLE_COLUMN = "titleName";

	public static final String LOCATION_COLUMN = "location";

	public static final String CREATOR_COLUMN = "creator";

	public static final String DATE_COLUMN = "startTime";

	public static final String STATUS_COLUMN = "availability";

	private String sortColumn;

	private boolean sortAscending;

	/* Static comparators */
	public static final Comparator<SignupMeetingWrapper> sortTitleComparator;

	public static final Comparator<SignupMeetingWrapper> sortLocationComparator;

	public static final Comparator<SignupMeetingWrapper> sortOwnerComparator;

	public static final Comparator<SignupMeetingWrapper> sortDateComparator;

	public static final Comparator<SignupMeetingWrapper> sortStatusComparator;
	static {
		sortTitleComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getMeeting().getTitle(),
						another.getMeeting().getTitle());
				return comparison == 0 ? sortDateComparator.compare(one, another) : comparison;
			}
		};

		sortLocationComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getMeeting().getLocation(),
						another.getMeeting().getLocation());
				return comparison == 0 ? sortDateComparator.compare(one, another) : comparison;
			}
		};

		sortOwnerComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getCreator(), another.getCreator());
				return comparison == 0 ? sortDateComparator.compare(one, another) : comparison;
			}
		};

		sortDateComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {

				Date date1 = one.getMeeting().getStartTime();
				Date date2 = another.getMeeting().getStartTime();

				if (date1 == null)
					return -1;
				int comparison = date1.compareTo(date2);
				if (comparison == 0) {
					return Collator.getInstance().compare(one.getMeeting().getId().toString(), another.getMeeting().getId().toString());
				}
				return comparison;
			}
		};

		sortStatusComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getAvailableStatus(), another.getAvailableStatus());
				return comparison == 0 ? sortDateComparator.compare(one, another) : comparison;
			}
		};
	}
<commit_msg>SIGNUP-125 fix comparators to use themselves rather than always use the date comparator<commit_after>/**********************************************************************************
 * $URL: https://source.sakaiproject.org/contrib/signup/branches/2-6-x/tool/src/java/org/sakaiproject/signup/tool/jsf/SignupSorter.java $
 * $Id: SignupSorter.java 56827 2009-01-13 21:52:18Z <EMAIL> $
***********************************************************************************
 *
 * Copyright (c) 2007, 2008, 2009 Yale University
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *      http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 *   
 * See the LICENSE.txt distributed with this file.
 *
 **********************************************************************************/
package org.sakaiproject.signup.tool.jsf;

import java.text.Collator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

/**
 * *
 * <p>
 * This class will provide sorting logic for Sign-up tool main page.
 * </P>
 * 
 * @author gl256
 * 
 */
public class SignupSorter {

	public static final String TITLE_COLUMN = "titleName";

	public static final String LOCATION_COLUMN = "location";

	public static final String CREATOR_COLUMN = "creator";

	public static final String DATE_COLUMN = "startTime";

	public static final String STATUS_COLUMN = "availability";

	private String sortColumn;

	private boolean sortAscending;

	/* Static comparators */
	public static final Comparator<SignupMeetingWrapper> sortTitleComparator;

	public static final Comparator<SignupMeetingWrapper> sortLocationComparator;

	public static final Comparator<SignupMeetingWrapper> sortOwnerComparator;

	public static final Comparator<SignupMeetingWrapper> sortDateComparator;

	public static final Comparator<SignupMeetingWrapper> sortStatusComparator;
	static {
		sortTitleComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getMeeting().getTitle(),
						another.getMeeting().getTitle());
				return comparison == 0 ? sortTitleComparator.compare(one, another) : comparison;
			}
		};

		sortLocationComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getMeeting().getLocation(),
						another.getMeeting().getLocation());
				return comparison == 0 ? sortLocationComparator.compare(one, another) : comparison;
			}
		};

		sortOwnerComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getCreator(), another.getCreator());
				return comparison == 0 ? sortOwnerComparator.compare(one, another) : comparison;
			}
		};

		sortDateComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {

				Date date1 = one.getMeeting().getStartTime();
				Date date2 = another.getMeeting().getStartTime();

				if (date1 == null)
					return -1;
				int comparison = date1.compareTo(date2);
				if (comparison == 0) {
					return Collator.getInstance().compare(one.getMeeting().getId().toString(), another.getMeeting().getId().toString());
				}
				return comparison;
			}
		};

		sortStatusComparator = new Comparator<SignupMeetingWrapper>() {
			public int compare(SignupMeetingWrapper one, SignupMeetingWrapper another) {
				int comparison = Collator.getInstance().compare(one.getAvailableStatus(), another.getAvailableStatus());
				return comparison == 0 ? sortStatusComparator.compare(one, another) : comparison;
			}
		};
	}

{'fraction_non_alphanumeric': 0.15334900117508812, 'fraction_numerical': 0.012103407755581668, 'mean_word_length': 4.97682584269663, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3111061', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2261, 'n_words': 618}