no_lines_match_your_filter_criteria=No lines match your filter criteria.
no_results=No results
over_x_days=over {0} days
+over_x_days.short={0} days
page_size=Page size
paging_first=First
paging_last=Last
shared_by=Shared by
show_more=Show more
since_x=since {0}
+since_x.short={0}
since_previous_analysis=since previous analysis
since_previous_analysis_detailed=since previous analysis ({0})
+since_previous_analysis.short=\u0394 last
+since_previous_analysis_detailed.short=\u0394 last ({0})
since_version=since version {0}
+since_version.short={0}
since_version_detailed=since version {0} ({1})
+since_version_detailed.short={0} ({1})
since_previous_version=since previous version
+since_previous_version.short=\u0394 version
since_previous_version_detailed=since previous version ({0})
+since_previous_version_detailed.short=\u0394 version ({0})
time_changes=Time changes
#------------------------------------------------------------------------------
}
public String label(Snapshot snapshot, int periodIndex) {
- String mode = snapshot.getPeriodMode(periodIndex);
- String param = snapshot.getPeriodModeParameter(periodIndex);
- Date date = snapshot.getPeriodDate(periodIndex);
+ return label(snapshot.getPeriodMode(periodIndex), snapshot.getPeriodModeParameter(periodIndex), snapshot.getPeriodDate(periodIndex));
+ }
- return label(mode, param, date);
+ public String abbreviation(Snapshot snapshot, int periodIndex) {
+ return abbreviation(snapshot.getPeriodMode(periodIndex), snapshot.getPeriodModeParameter(periodIndex), snapshot.getPeriodDate(periodIndex));
}
public String label(int periodIndex) {
String periodProperty = settings.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex);
PeriodParameters periodParameters = new PeriodParameters(periodProperty);
+ return label(periodParameters.getMode(), periodParameters.getParam(), periodParameters.getDate());
+ }
- String mode = periodParameters.getMode();
- String param = periodParameters.getParam();
- Date date = periodParameters.getDate();
-
- return label(mode, param, date);
+ public String abbreviation(int periodIndex) {
+ String periodProperty = settings.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex);
+ PeriodParameters periodParameters = new PeriodParameters(periodProperty);
+ return abbreviation(periodParameters.getMode(), periodParameters.getParam(), periodParameters.getDate());
}
public String label(String mode, String param, Date date) {
- String label = "";
+ return label(mode, param, date, false);
+ }
+
+ public String abbreviation(String mode, String param, Date date) {
+ return label(mode, param, date, true);
+ }
+
+ private String label(String mode, String param, Date date, boolean shortLabel) {
+ String label;
if (CoreProperties.TIMEMACHINE_MODE_DAYS.equals(mode)) {
- label = message("over_x_days", param);
+ label = label("over_x_days", shortLabel, param);
} else if (CoreProperties.TIMEMACHINE_MODE_VERSION.equals(mode)) {
- label = message("since_version", param);
+ label = label("since_version", shortLabel, param);
if (date != null) {
- label = message("since_version_detailed", param, convertDate(date));
+ label = label("since_version_detailed", shortLabel, param, convertDate(date));
}
} else if (CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS.equals(mode)) {
- label = message("since_previous_analysis");
+ label = label("since_previous_analysis", shortLabel);
if (date != null) {
- label = message("since_previous_analysis_detailed", convertDate(date));
+ label = label("since_previous_analysis_detailed", shortLabel, convertDate(date));
}
} else if (CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION.equals(mode)) {
- label = message("since_previous_version");
+ label = label("since_previous_version", shortLabel);
if (param != null) {
- label = message("since_previous_version_detailed", param);
+ label = label("since_previous_version_detailed", shortLabel, param);
}
} else if (CoreProperties.TIMEMACHINE_MODE_DATE.equals(mode)) {
- label = message("since_x", convertDate(date));
+ label = label("since_x", shortLabel, convertDate(date));
} else {
throw new IllegalArgumentException("This mode is not supported : " + mode);
}
return label;
}
- private String message(String key, Object... parameters) {
- return i18n.message(getLocale(), key, null, parameters);
+ private String label(String key, boolean shortLabel, Object... parameters) {
+ String msgKey = key;
+ if (shortLabel) {
+ msgKey += ".short";
+ }
+ return i18n.message(getLocale(), msgKey, null, parameters);
}
private String convertDate(Date date) {
private static class PeriodParameters {
- private String mode;
- private String param;
- private Date date;
+ private String mode = null;
+ private String param = null;
+ private Date date = null;
public PeriodParameters(String periodProperty) {
if (CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS.equals(periodProperty) || CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION.equals(periodProperty)) {
}
@Test
- public void shouldReturnSnapshotLabelInModeDays() {
+ public void label_of_duration_in_days() {
when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_DAYS);
when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
}
@Test
- public void shouldReturnSnapshotLabelInModeVersion() {
+ public void abbreviation_of_duration_in_days() {
+ when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_DAYS);
+ when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
+ when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
+
+ periods.abbreviation(snapshot, periodIndex);
+ verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("over_x_days.short"), Mockito.isNull(String.class), Mockito.eq(param));
+ }
+
+ @Test
+ public void label_of_snapshot_version() {
when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_VERSION);
when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
}
@Test
- public void shouldReturnSnapshotLabelInModePreviousAnalysisWithDateNotNull() {
+ public void abbreviation_of_snapshot_version() {
+ when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_VERSION);
+ when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
+ when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
+
+ periods.abbreviation(snapshot, periodIndex);
+ verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_version_detailed.short"), Mockito.isNull(String.class), Mockito.eq(param), Mockito.anyString());
+ }
+
+ @Test
+ public void label_of_previous_analysis_with_date() {
when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
}
@Test
- public void shouldReturnSnapshotLabelInModePreviousAnalysisWithNullDate() {
+ public void label_of_previous_analysis_without_date() {
when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
when(snapshot.getPeriodDate(periodIndex)).thenReturn(null);
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis"), Mockito.isNull(String.class));
}
+ @Test
+ public void abbreviation_of_previous_analysis_with_date() {
+ when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
+ when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
+
+ periods.abbreviation(snapshot, periodIndex);
+ verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis_detailed.short"), Mockito.isNull(String.class), Mockito.anyString());
+ }
+
+ @Test
+ public void abbreviation_of_previous_analysis_without_date() {
+ when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
+ when(snapshot.getPeriodDate(periodIndex)).thenReturn(null);
+ when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
+
+ periods.abbreviation(snapshot, periodIndex);
+ verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis.short"), Mockito.isNull(String.class));
+ }
+
@Test
public void shouldReturnSnapshotLabelInModePreviousVersionWithParamNotNull() {
when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
}
@Test
- public void shouldReturnLabelInModePreviousVersion() {
+ public void label_of_previous_version() {
int periodIndex = 1;
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
}
@Test
- public void shouldReturnLabelInModeDate() {
+ public void abbreviation_of_previous_version() {
+ int periodIndex = 1;
+ settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
+
+ periods.abbreviation(periodIndex);
+ verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_version.short"), Mockito.isNull(String.class));
+ }
+
+ @Test
+ public void label_of_date() {
int periodIndex = 1;
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, "2012-12-12");
verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_x"), Mockito.isNull(String.class), Mockito.anyString());
}
+ @Test
+ public void abbreviation_of_date() {
+ int periodIndex = 1;
+ settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, "2012-12-12");
+
+ periods.abbreviation(periodIndex);
+
+ verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_x.short"), Mockito.isNull(String.class), Mockito.anyString());
+ }
+
@Test(expected = IllegalArgumentException.class)
public void shouldNotSupportUnknownModeForLabel() {
int periodIndex = 1;
public void ruleSeverityChanged(int parentProfileId, int activeRuleId, int oldSeverityId, int newSeverityId, String userName) {
getProfilesManager().ruleSeverityChanged(parentProfileId, activeRuleId, RulePriority.values()[oldSeverityId],
- RulePriority.values()[newSeverityId], userName);
+ RulePriority.values()[newSeverityId], userName);
}
public void ruleDeactivated(int parentProfileId, int deactivatedRuleId, String userName) {
// notifier is null when creating the administrator in the migration script 011.
if (notifier != null) {
notifier.onNewUser(NewUserHandler.Context.builder()
- .setLogin(fields.get("login"))
- .setName(fields.get("name"))
- .setEmail(fields.get("email"))
- .build());
+ .setLogin(fields.get("login"))
+ .setName(fields.get("name"))
+ .setEmail(fields.get("email"))
+ .build());
}
}
public String getPeriodLabel(String mode, String param, Date date) {
return get(Periods.class).label(mode, param, date);
}
+
+ public String getPeriodAbbreviation(int periodIndex) {
+ return get(Periods.class).abbreviation(periodIndex);
+ }
}
html=h(column.title_label)
end
if column.period
- html += "<br><span class='note'>#{Api::Utils.period_label(column.period)}</small>"
+ html += "<br><span class='note'>#{Api::Utils.period_abbreviation(column.period)}</small>"
end
if filter.sort_key==column.key
html << (filter.sort_asc? ? image_tag("asc12.png") : image_tag("desc12.png"))
def self.period_label(index)
java_facade.getPeriodLabel(index)
end
+
+ # Abbreviated label of global periods
+ # index is in [1..3]
+ def self.period_abbreviation(index)
+ java_facade.getPeriodAbbreviation(index)
+ end
end