String author();
- Integer executionTime();
-
Map<String, String> details();
String message();
Map<String, String> getDetails();
- int getExecutionTime();
-
}
private Activity.Type type;
private String author;
- private Integer executionTime;
-
private String data;
protected ActivityDto() {
return this;
}
- public Integer getExecutionTime() {
- return executionTime;
- }
-
public ActivityDto setExecutionTime(Integer executionTime) {
- this.executionTime = executionTime;
return this;
}
public static ActivityDto createFor(ActivityLog activityLog) {
return new ActivityDto()
- .setData(KeyValueFormat.format(activityLog.getDetails()))
- .setExecutionTime(activityLog.getExecutionTime());
+ .setData(KeyValueFormat.format(activityLog.getDetails()));
}
}
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 547;
+ public static final int LAST_VERSION = 548;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
loadAlias(conf, "ActiveRule", ActiveRuleDto.class);
loadAlias(conf, "ActiveRuleParam", ActiveRuleParamDto.class);
loadAlias(conf, "RequirementMigration", RequirementMigrationDto.class);
- loadAlias(conf, "Log", ActivityDto.class);
+ loadAlias(conf, "Activity", ActivityDto.class);
// AuthorizationMapper has to be loaded before IssueMapper because this last one used it
loadMapper(conf, "org.sonar.core.user.AuthorizationMapper");
<mapper namespace="org.sonar.core.activity.db.ActivityMapper">
-<insert id="insert" parameterType="Log" useGeneratedKeys="false" lang="raw">
- insert into logs
- (created_at, log_type,execution_time_field,user_login,data_field, log_message)
- values (#{createdAt}, #{type}, #{executionTime}, #{author}, #{data}, #{message})
+ <insert id="insert" parameterType="Activity" useGeneratedKeys="false" lang="raw">
+ insert into activities
+ (created_at, log_type,user_login,data_field, log_message)
+ values (#{createdAt}, #{type}, #{author}, #{data}, #{message})
</insert>
- <select id="selectByKey" parameterType="map" resultType="Log" lang="raw">
+ <select id="selectByKey" parameterType="map" resultType="Activity" lang="raw">
SELECT
l.created_at as "createdAt",
l.log_type as "type",
- l.execution_time_field as "executionTime",
l.user_login as "author",
l.data_field as "data",
l.log_message as "message"
- FROM logs l
+ FROM activities l
WHERE l.created_at=#{key.createdAt}
AND l.user_login=#{key.author}
AND l.log_type=#{key.type}
</select>
- <select id="selectAll" parameterType="map" resultType="Log" lang="raw">
+ <select id="selectAll" parameterType="map" resultType="Activity" lang="raw">
SELECT
l.created_at as "createdAt",
l.log_type as "type",
- l.execution_time_field as "executionTime",
l.user_login as "author",
l.data_field as "data",
l.log_message as "message"
- FROM logs l
+ FROM activities l
</select>
</mapper>
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('545');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('546');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('547');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('548');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
);
-CREATE TABLE "LOGS" (
+CREATE TABLE "ACTIVITIES" (
"CREATED_AT" TIMESTAMP,
- "EXECUTION_TIME_FIELD" LONG,
"USER_LOGIN" VARCHAR(30),
"LOG_TYPE" VARCHAR(250),
"LOG_MESSAGE" VARCHAR(250),
return this.getField(ActivityNormalizer.LogFields.AUTHOR.field());
}
- @Override
- public Integer executionTime() {
- return this.getField(ActivityNormalizer.LogFields.EXECUTION.field());
- }
-
@Override
public Map<String, String> details() {
return this.getField(ActivityNormalizer.LogFields.DETAILS.field());
public static final class LogFields extends Indexable {
- public final static IndexField KEY = addSortableAndSearchable(IndexField.Type.STRING, "key");
public final static IndexField TYPE = addSortable(IndexField.Type.STRING, "type");
public final static IndexField DATE = addSortable(IndexField.Type.DATE, "date");
- public final static IndexField EXECUTION = add(IndexField.Type.NUMERIC, "executionTime");
public final static IndexField AUTHOR = addSearchable(IndexField.Type.STRING, "author");
public final static IndexField DETAILS = addSearchable(IndexField.Type.OBJECT, "details");
public final static IndexField MESSAGE = addSearchable(IndexField.Type.STRING, "message");
public List<UpdateRequest> normalize(ActivityDto dto) {
Map<String, Object> logDoc = new HashMap<String, Object>();
- logDoc.put(LogFields.KEY.field(), dto.getKey());
logDoc.put(LogFields.TYPE.field(), dto.getType());
logDoc.put(LogFields.AUTHOR.field(), dto.getAuthor());
logDoc.put(LogFields.MESSAGE.field(), dto.getMessage());
- logDoc.put(LogFields.EXECUTION.field(), dto.getExecutionTime());
logDoc.put(LogFields.DATE.field(), dto.getCreatedAt());
logDoc.put(LogFields.DETAILS.field(), KeyValueFormat.parse(dto.getData()));
public ActivityMapping(Languages languages, MacroInterpreter macroInterpreter) {
super();
- addIndexStringField("key", ActivityNormalizer.LogFields.KEY.field());
addIndexStringField("type", ActivityNormalizer.LogFields.TYPE.field());
addIndexDatetimeField("createdAt", ActivityNormalizer.LogFields.DATE.field());
addIndexStringField("userLogin", ActivityNormalizer.LogFields.AUTHOR.field());
addIndexStringField("message", ActivityNormalizer.LogFields.MESSAGE.field());
- addIndexStringField("executionTime", ActivityNormalizer.LogFields.EXECUTION.field());
addField("details", new DetailField());
}
return details;
}
- @Override
- public int getExecutionTime() {
- return (int) (System.currentTimeMillis() - start);
- }
-
public static ActiveRuleChange createFor(Type type, ActiveRuleKey key) {
return new ActiveRuleChange(type, key);
}
--- /dev/null
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+#
+# Sonar 2.14
+#
+class RenameActivitiesTable < ActiveRecord::Migration
+
+ def self.up
+ remove_column(:logs, 'execution_time_field')
+ rename_table(:logs, 'activities')
+ end
+
+end
return ImmutableMap.of(testKey, testValue);
}
- @Override
- public int getExecutionTime() {
- return 12;
- }
});
dbSession.commit();
Activity activity = Iterables.getFirst(index.findAll().getHits(), null);
assertThat(activity).isNotNull();
assertThat(activity.details().get(testKey)).isEqualTo(testValue);
- assertThat(activity.executionTime()).isEqualTo(12);
}
@Test
public Map<String, String> getDetails() {
return ImmutableMap.of(testKey, testValue);
}
-
- @Override
- public int getExecutionTime() {
- return 12;
- }
})
.setAuthor("jUnit")
.setType(Activity.Type.ACTIVE_RULE);
assertThat(dao.findAll(session)).hasSize(1);
ActivityDto newDto = dao.getByKey(session, log.getKey());
assertThat(newDto.getAuthor()).isEqualTo(log.getAuthor());
- assertThat(newDto.getExecutionTime()).isEqualTo(12);
assertThat(newDto.getData()).isNotNull();
Map<String, String> details = KeyValueFormat.parse(newDto.getData());
assertThat(details.get(testKey)).isEqualTo(testValue);