<commit_before>package edu.northwestern.bioinformatics.studycalendar.web.template.period;

import edu.northwestern.bioinformatics.studycalendar.StudyCalendarError;
import edu.northwestern.bioinformatics.studycalendar.domain.Activity;
import edu.northwestern.bioinformatics.studycalendar.domain.PlannedActivity;
import edu.northwestern.bioinformatics.studycalendar.tools.BeanPropertyListComparator;
import org.apache.commons.collections.comparators.NullComparator;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Collections;
import java.util.TreeSet;

/**
 * @author <NAME>
*/
public class PeriodActivitiesGridRowKey implements Comparable<PeriodActivitiesGridRowKey> {
        private final Logger log = LoggerFactory.getLogger(getClass());

    private static final BeanPropertyListComparator<PeriodActivitiesGridRowKey> COMPARATOR
        = new BeanPropertyListComparator<PeriodActivitiesGridRowKey>().
            addProperty("details", new NullComparator(String.CASE_INSENSITIVE_ORDER)).
            addProperty("condition", new NullComparator(String.CASE_INSENSITIVE_ORDER)).
            addProperty("comparableLabels", new NullComparator(String.CASE_INSENSITIVE_ORDER));

    private Integer activityId;
    protected String details;
    protected String condition;
    protected Collection<String> labels;
    protected Integer weight;

    public static PeriodActivitiesGridRowKey create(Activity activity) {
        return new PeriodActivitiesGridRowKey(
            activity.getId(), null, null, Collections.<String>emptySet(), 0
        );
    }

    public static PeriodActivitiesGridRowKey create(PlannedActivity plannedActivity) {
        if (plannedActivity.getActivity().getId() == null) {
            throw new StudyCalendarError("Cannot build a useful key if the activity has no ID");
        }
        return new PeriodActivitiesGridRowKey(
            plannedActivity.getActivity().getId(),
            plannedActivity.getDetails(),
            plannedActivity.getCondition(),
            plannedActivity.getLabels(),
            plannedActivity.getWeight()
        );
    }

    public PeriodActivitiesGridRowKey(Integer activityId, String details, String condition, Collection<String> labels, Integer weight) {
        this.activityId = activityId;
        this.details = details;
        this.condition = condition;
        this.labels = new TreeSet<String>(labels);
        this.weight = weight;
    }<commit_msg>Commit for bugs #1026 - Fixed the weight value, taht was set to 0 for every planned activity, even when weight wasn't edited.<commit_after>package edu.northwestern.bioinformatics.studycalendar.web.template.period;

import edu.northwestern.bioinformatics.studycalendar.StudyCalendarError;
import edu.northwestern.bioinformatics.studycalendar.domain.Activity;
import edu.northwestern.bioinformatics.studycalendar.domain.PlannedActivity;
import edu.northwestern.bioinformatics.studycalendar.tools.BeanPropertyListComparator;
import org.apache.commons.collections.comparators.NullComparator;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Collections;
import java.util.TreeSet;

/**
 * @author <NAME>
*/
public class PeriodActivitiesGridRowKey implements Comparable<PeriodActivitiesGridRowKey> {
        private final Logger log = LoggerFactory.getLogger(getClass());

    private static final BeanPropertyListComparator<PeriodActivitiesGridRowKey> COMPARATOR
        = new BeanPropertyListComparator<PeriodActivitiesGridRowKey>().
            addProperty("details", new NullComparator(String.CASE_INSENSITIVE_ORDER)).
            addProperty("condition", new NullComparator(String.CASE_INSENSITIVE_ORDER)).
            addProperty("comparableLabels", new NullComparator(String.CASE_INSENSITIVE_ORDER));

    private Integer activityId;
    protected String details;
    protected String condition;
    protected Collection<String> labels;
    protected Integer weight;

    public static PeriodActivitiesGridRowKey create(Activity activity) {
        return new PeriodActivitiesGridRowKey(
            activity.getId(), null, null, Collections.<String>emptySet(), null
        );
    }

    public static PeriodActivitiesGridRowKey create(PlannedActivity plannedActivity) {
        if (plannedActivity.getActivity().getId() == null) {
            throw new StudyCalendarError("Cannot build a useful key if the activity has no ID");
        }
        return new PeriodActivitiesGridRowKey(
            plannedActivity.getActivity().getId(),
            plannedActivity.getDetails(),
            plannedActivity.getCondition(),
            plannedActivity.getLabels(),
            plannedActivity.getWeight()
        );
    }

    public PeriodActivitiesGridRowKey(Integer activityId, String details, String condition, Collection<String> labels, Integer weight) {
        this.activityId = activityId;
        this.details = details;
        this.condition = condition;
        this.labels = new TreeSet<String>(labels);
        this.weight = weight;
    }
{'fraction_non_alphanumeric': 0.08363846598573907, 'fraction_numerical': 0.001927153594141453, 'mean_word_length': 4.053554040895813, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3879101', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1292, 'n_words': 283}