aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-02-11 15:05:15 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-02-17 17:34:37 +0100
commit1f5a84ff501e6404a7a2a89c166dde0ba46bceb2 (patch)
tree0760aa2bc95cfeee8f16aa1ae1ef8e4ac0928678 /sonar-plugin-api/src
parent1af0c2e7482eaa4912a1c9aef1f98cfb1c3c10f4 (diff)
downloadsonarqube-1f5a84ff501e6404a7a2a89c166dde0ba46bceb2.tar.gz
sonarqube-1f5a84ff501e6404a7a2a89c166dde0ba46bceb2.zip
SONAR-6163 - timezones - events migration
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java25
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java3
3 files changed, 17 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
index 8c802c2ca98..eb4db71fe41 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
@@ -26,6 +26,9 @@ import org.sonar.api.database.model.Snapshot;
import javax.persistence.*;
import java.util.Date;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.sonar.api.utils.DateUtils.longToDate;
+
/**
* @since 1.10
*/
@@ -46,10 +49,10 @@ public class Event extends BaseIdentifiable {
private String category;
@Column(name = "event_date", updatable = true, nullable = false)
- private Date date;
+ private Long date;
- @Column(name = "created_at", updatable = true, nullable = true)
- private Date createdAt;
+ @Column(name = "created_at", updatable = true, nullable = false)
+ private Long createdAt;
@Column(name = "event_data", updatable = true, nullable = true)
private String data;
@@ -103,11 +106,11 @@ public class Event extends BaseIdentifiable {
}
public Date getDate() {
- return date;
+ return longToDate(date);
}
public void setDate(Date date) {
- this.date = date;
+ this.date = date.getTime();
}
public Snapshot getSnapshot() {
@@ -115,19 +118,17 @@ public class Event extends BaseIdentifiable {
}
public Date getCreatedAt() {
- return createdAt;
+ return new Date(createdAt);
}
public void setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
+ this.createdAt = createdAt.getTime();
}
public final void setSnapshot(Snapshot snapshot) {
- this.snapshot = snapshot;
- if (snapshot != null) {
- this.date = (snapshot.getCreatedAtMs() == null ? null : new Date(snapshot.getCreatedAtMs()));
- this.resourceId = snapshot.getResourceId();
- }
+ this.snapshot = checkNotNull(snapshot, "it is not possible to set a null snapshot linked to an event");
+ this.date = snapshot.getCreatedAtMs();
+ this.resourceId = snapshot.getResourceId();
}
public Integer getResourceId() {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
index b75209e1538..00fd00d8314 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
@@ -30,6 +30,7 @@ import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.Collection;
@@ -242,7 +243,7 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext
* @param date the event date
* @return the created event
*/
- Event createEvent(Resource resource, String name, String description, String category, Date date);
+ Event createEvent(Resource resource, String name, @Nullable String description, String category, @Nullable Date date);
/**
* Deletes an event
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
index f21b83bab5f..6714ed9c1bb 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
@@ -30,6 +30,7 @@ import org.sonar.api.rules.Violation;
import org.sonar.graph.DirectedGraphAccessor;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Date;
@@ -155,7 +156,7 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
public abstract void deleteEvent(Event event);
- public abstract Event addEvent(Resource resource, String name, String description, String category, Date date);
+ public abstract Event addEvent(Resource resource, String name, String description, String category, @Nullable Date date);
public final Collection<Dependency> getOutgoingDependencies(Resource from) {
return getOutgoingEdges(from);