private void writeChangelog(Issue issue, JsonWriter json) { json.name("changelog") .beginArray() .beginObject() .prop("creationDate", DateUtils.formatDateTime(issue.creationDate())) .prop("fCreationDate", formatDate(issue.creationDate())) .name("diffs") .beginArray() .value(i18n.message(UserSession.get().locale(), "created", null)) .endArray() .endObject(); IssueChangelog changelog = issueChangelogService.changelog(issue); for (FieldDiffs diffs : changelog.changes()) { String userLogin = diffs.userLogin(); json.beginObject() .prop("userName", userLogin != null ? changelog.user(diffs).name() : null) .prop("creationDate", DateUtils.formatDateTime(diffs.creationDate())) .prop("fCreationDate", formatDate(diffs.creationDate())); json.name("diffs").beginArray(); List<String> diffsFormatted = issueChangelogService.formatDiffs(diffs); for (String diff : diffsFormatted) { json.value(diff); } json.endArray(); json.endObject(); } json.endArray(); }
public Settings setProperty(String key, @Nullable Date date, boolean includeTime) { if (date == null) { return removeProperty(key); } return setProperty( key, includeTime ? DateUtils.formatDateTime(date) : DateUtils.formatDate(date)); }
public void add(String language, String name) { qualityProfiles.add( QualityProfile.newBuilder() .setLanguage(language) .setKey(name) .setName(name) .setRulesUpdatedAt(DateUtils.formatDateTime(new Date(1234567891212L))) .build()); }
private void delete(List<PurgeableSnapshotDto> snapshots, DbSession session) { for (PurgeableSnapshotDto snapshot : snapshots) { LOG.debug( "<- Delete snapshot: {} [{}]", DateUtils.formatDateTime(snapshot.getDate()), snapshot.getSnapshotId()); purgeDao.deleteSnapshots( PurgeSnapshotQuery.create().setRootSnapshotId(snapshot.getSnapshotId()), session); purgeDao.deleteSnapshots( PurgeSnapshotQuery.create().setId(snapshot.getSnapshotId()), session); } }
private void writeIssue(IssueQueryResult result, DefaultIssue issue, JsonWriter json) { Component component = result.component(issue); Component project = result.project(issue); String actionPlanKey = issue.actionPlanKey(); WorkDayDuration technicalDebt = issue.technicalDebt(); Date updateDate = issue.updateDate(); Date closeDate = issue.closeDate(); json.prop("key", issue.key()) .prop("component", issue.componentKey()) .prop("componentLongName", component != null ? component.longName() : null) .prop("componentQualifier", component != null ? component.qualifier() : null) .prop("project", issue.projectKey()) .prop("projectLongName", project != null ? project.longName() : null) .prop("rule", issue.ruleKey().toString()) .prop("ruleName", result.rule(issue).getName()) .prop("line", issue.line()) .prop("message", issue.message()) .prop("resolution", issue.resolution()) .prop("status", issue.status()) .prop("severity", issue.severity()) .prop("author", issue.authorLogin()) .prop("actionPlan", actionPlanKey) .prop( "debt", technicalDebt != null ? technicalDebtFormatter.format(UserSession.get().locale(), technicalDebt) : null) .prop("actionPlanName", actionPlanKey != null ? result.actionPlan(issue).name() : null) .prop("creationDate", DateUtils.formatDateTime(issue.creationDate())) .prop("fCreationDate", formatDate(issue.creationDate())) .prop("updateDate", updateDate != null ? DateUtils.formatDateTime(updateDate) : null) .prop("fUpdateDate", formatDate(updateDate)) .prop("fUpdateAge", formatAgeDate(updateDate)) .prop("closeDate", closeDate != null ? DateUtils.formatDateTime(closeDate) : null) .prop("fCloseDate", formatDate(issue.closeDate())); addUserWithLabel(result, issue.assignee(), "assignee", json); addUserWithLabel(result, issue.reporter(), "reporter", json); }
protected void appendFooter(StringBuilder message, Notification notification) { String projectKey = notification.getFieldValue(FIELD_PROJECT_KEY); String dateString = notification.getFieldValue(FIELD_PROJECT_DATE); if (projectKey != null && dateString != null) { Date date = DateUtils.parseDateTime(dateString); String url = String.format( "%s/component_issues?id=%s#createdAt=%s", settings.getServerBaseURL(), encode(projectKey), encode(DateUtils.formatDateTime(date))); message.append("See it in SonarQube: ").append(url).append(NEW_LINE); } }
private void writeComments(IssueQueryResult queryResult, Issue issue, JsonWriter json) { json.name("comments").beginArray(); for (IssueComment comment : issue.comments()) { String userLogin = comment.userLogin(); json.beginObject() .prop("key", comment.key()) .prop("userName", userLogin != null ? queryResult.user(userLogin).name() : null) .prop("raw", comment.markdownText()) .prop("html", Markdown.convertToHtml(comment.markdownText())) .prop("createdAt", DateUtils.formatDateTime(comment.createdAt())) .prop("fCreatedAge", formatAgeDate(comment.createdAt())) .prop( "updatable", UserSession.get().isLoggedIn() && UserSession.get().login().equals(comment.userLogin())) .endObject(); } json.endArray(); }
private void writeResponse(JsonWriter json, Result<QProfileActivity> result, Paging paging) { json.beginObject(); json.prop("total", result.getTotal()); json.prop(Param.PAGE, paging.pageIndex()); json.prop(Param.PAGE_SIZE, paging.pageSize()); json.name("events").beginArray(); for (QProfileActivity event : result.getHits()) { json.beginObject() .prop("date", DateUtils.formatDateTime(event.getCreatedAt())) .prop("authorLogin", event.getLogin()) .prop("authorName", event.authorName()) .prop("action", event.getAction()) .prop("ruleKey", event.ruleKey().toString()) .prop("ruleName", event.ruleName()); writeParameters(json, event); json.endObject(); } json.endArray(); json.endObject().close(); }
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller .createAction("activity") .setDescription( format( "Search for tasks.<br> " + "Requires the system administration permission, " + "or project administration permission if %s is set.<br/>" + "Since 5.5, it's no more possible to specify the page parameter", PARAM_COMPONENT_ID)) .setResponseExample(getClass().getResource("activity-example.json")) .setHandler(this) .setSince("5.2"); action .createParam(PARAM_COMPONENT_ID) .setDescription("Id of the component (project) to filter on") .setExampleValue(Uuids.UUID_EXAMPLE_03); action .createParam(PARAM_COMPONENT_QUERY) .setDescription( format( "Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + "<li>component keys that are exactly the same as the supplied string</li>" + "</ul>" + "Must not be set together with %s.<br />" + "Deprecated and replaced by '%s'", PARAM_COMPONENT_ID, Param.TEXT_QUERY)) .setExampleValue("Apache") .setDeprecatedSince("5.5"); action .createParam(Param.TEXT_QUERY) .setDescription( format( "Limit search to: <ul>" + "<li>component names that contain the supplied string</li>" + "<li>component keys that are exactly the same as the supplied string</li>" + "<li>task ids that are exactly the same as the supplied string</li>" + "</ul>" + "Must not be set together with %s", PARAM_COMPONENT_ID)) .setExampleValue("Apache") .setSince("5.5"); action .createParam(PARAM_STATUS) .setDescription("Comma separated list of task statuses") .setPossibleValues( ImmutableList.builder() .add(CeActivityDto.Status.values()) .add(CeQueueDto.Status.values()) .build()) .setExampleValue( Joiner.on(",").join(CeQueueDto.Status.IN_PROGRESS, CeActivityDto.Status.SUCCESS)) // activity statuses by default to be backward compatible // queued tasks have been added in 5.5 .setDefaultValue(Joiner.on(",").join(CeActivityDto.Status.values())); action .createParam(PARAM_ONLY_CURRENTS) .setDescription("Filter on the last tasks (only the most recent finished task by project)") .setBooleanPossibleValues() .setDefaultValue("false"); action .createParam(PARAM_TYPE) .setDescription("Task type") .setExampleValue(CeTaskTypes.REPORT) .setPossibleValues(taskTypes); action .createParam(PARAM_MIN_SUBMITTED_AT) .setDescription("Minimum date of task submission (inclusive)") .setExampleValue(DateUtils.formatDateTime(new Date())); action .createParam(PARAM_MAX_EXECUTED_AT) .setDescription("Maximum date of end of task processing (inclusive)") .setExampleValue(DateUtils.formatDateTime(new Date())); action .createParam(Param.PAGE) .setDescription("Deprecated parameter") .setDeprecatedSince("5.5") .setDeprecatedKey("pageIndex"); action.addPageSize(100, MAX_PAGE_SIZE); }
private void addDate(@Nullable Date date, String dateKey, JsonWriter json) { if (date != null) { json.prop(dateKey, DateUtils.formatDateTime(date)); } }