<commit_before>package org.mtransit.android.commons.data;

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;

import org.mtransit.android.commons.ComparatorUtils;
import org.mtransit.android.commons.MTLog;
import org.mtransit.android.commons.TimeUtils;
import org.mtransit.android.commons.provider.ServiceUpdateProvider;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.text.TextUtils;

public class ServiceUpdate implements MTLog.Loggable {

	private static final String TAG = ServiceUpdate.class.getSimpleName();

	@Override
	public String getLogTag() {
		return TAG;
	}

	public static final HigherSeverityFirstComparator HIGHER_SEVERITY_FIRST_COMPARATOR = new HigherSeverityFirstComparator();

	// order and values are important (force DB reset when changing values)
	public static final int SEVERITY_NONE = 0; // no message
	public static final int SEVERITY_INFO_UNKNOWN = 1; // unexpected information message
	public static final int SEVERITY_INFO_AGENCY = 2; // concerns most if not all POIs in this agency
	public static final int SEVERITY_INFO_RELATED_POI = 3; // RTS other stops on the same route [trip]
	public static final int SEVERITY_INFO_POI = 4; // related to this POI but not warning
	public static final int SEVERITY_WARNING_UNKNOWN = 5; // unexpected warning message
	public static final int SEVERITY_WARNING_RELATED_POI = 6; // related to this POI and it's important enough to bother user with it
	public static final int SEVERITY_WARNING_POI = 7; // related to this POI and it's important enough to bother user with it

	private Integer id; // internal DB ID (useful to delete) OR NULL
	private String targetUUID;
	private long lastUpdateInMs;
	private long maxValidityInMs;
	private String text;
	private String textHTML;
	private int severity;
	private String language;
	private String sourceLabel;
	private String sourceId;

	public ServiceUpdate(Integer optId, String targetUUID, long lastUpdateInMs, long maxValidityInMs, String text, String optTextHTML, int severity,
			String sourceId, String sourceLabel, String language) {
		this.id = optId;
		this.targetUUID = targetUUID;
		this.lastUpdateInMs = lastUpdateInMs;
		this.maxValidityInMs = maxValidityInMs;
		this.text = text;
		this.textHTML = optTextHTML;
		this.severity = severity;
		this.sourceId = sourceId;
		this.sourceLabel = sourceLabel;
		this.language = language;
	}

	public void setTargetUUID(String targetUUID) {
		this.targetUUID = targetUUID;
	}

	public String getTargetUUID() {
		return targetUUID;
	}

	public boolean isSeverityWarning() {
		return isSeverityWarning(this.severity);
	}

	public static boolean isSeverityWarning(int severity) {
		return severity == SEVERITY_WARNING_UNKNOWN //<commit_msg>Add new service update severity for agency wide warnings.<commit_after>package org.mtransit.android.commons.data;

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;

import org.mtransit.android.commons.ComparatorUtils;
import org.mtransit.android.commons.MTLog;
import org.mtransit.android.commons.TimeUtils;
import org.mtransit.android.commons.provider.ServiceUpdateProvider;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.text.TextUtils;

public class ServiceUpdate implements MTLog.Loggable {

	private static final String TAG = ServiceUpdate.class.getSimpleName();

	@Override
	public String getLogTag() {
		return TAG;
	}

	public static final HigherSeverityFirstComparator HIGHER_SEVERITY_FIRST_COMPARATOR = new HigherSeverityFirstComparator();

	// order and values are important (force DB reset when changing values)
	public static final int SEVERITY_NONE = 0; // no message
	public static final int SEVERITY_INFO_UNKNOWN = 1; // unexpected information message
	public static final int SEVERITY_INFO_AGENCY = 2; // concerns most if not all POIs in this agency
	public static final int SEVERITY_INFO_RELATED_POI = 3; // RTS other stops on the same route [trip]
	public static final int SEVERITY_INFO_POI = 4; // related to this POI but not warning
	public static final int SEVERITY_WARNING_UNKNOWN = 5; // unexpected warning message
	public static final int SEVERITY_WARNING_AGENCY = 6; // unexpected warning message
	public static final int SEVERITY_WARNING_RELATED_POI = 7; // related to this POI and it's important enough to bother user with it
	public static final int SEVERITY_WARNING_POI = 8; // related to this POI and it's important enough to bother user with it

	private Integer id; // internal DB ID (useful to delete) OR NULL
	private String targetUUID;
	private long lastUpdateInMs;
	private long maxValidityInMs;
	private String text;
	private String textHTML;
	private int severity;
	private String language;
	private String sourceLabel;
	private String sourceId;

	public ServiceUpdate(Integer optId, String targetUUID, long lastUpdateInMs, long maxValidityInMs, String text, String optTextHTML, int severity,
			String sourceId, String sourceLabel, String language) {
		this.id = optId;
		this.targetUUID = targetUUID;
		this.lastUpdateInMs = lastUpdateInMs;
		this.maxValidityInMs = maxValidityInMs;
		this.text = text;
		this.textHTML = optTextHTML;
		this.severity = severity;
		this.sourceId = sourceId;
		this.sourceLabel = sourceLabel;
		this.language = language;
	}

	public void setTargetUUID(String targetUUID) {
		this.targetUUID = targetUUID;
	}

	public String getTargetUUID() {
		return targetUUID;
	}

	public boolean isSeverityWarning() {
		return isSeverityWarning(this.severity);
	}

	public static boolean isSeverityWarning(int severity) {
		return severity == SEVERITY_WARNING_UNKNOWN //
				|| severity == SEVERITY_WARNING_AGENCY //
{'fraction_non_alphanumeric': 0.06812694032424974, 'fraction_numerical': 0.002932045532942394, 'mean_word_length': 5.021806853582555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5214069', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1685, 'n_words': 555}