summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/tickets/ITicketService.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-04-28 14:56:15 -0400
committerJames Moger <james.moger@gitblit.com>2014-05-02 15:31:01 -0400
commit4d81c92b668bce79d7db7bc278f0d399fe693e65 (patch)
tree04e98e6182deeb78724d9a39a1d9c25a8efa10d2 /src/main/java/com/gitblit/tickets/ITicketService.java
parenta98ebb22fd088bbc2e40d752b065e4eb2210a734 (diff)
downloadgitblit-4d81c92b668bce79d7db7bc278f0d399fe693e65.tar.gz
gitblit-4d81c92b668bce79d7db7bc278f0d399fe693e65.zip
Implementation of a ticket mgration tool
Diffstat (limited to 'src/main/java/com/gitblit/tickets/ITicketService.java')
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java
index 3261ca96..a6a7a75a 100644
--- a/src/main/java/com/gitblit/tickets/ITicketService.java
+++ b/src/main/java/com/gitblit/tickets/ITicketService.java
@@ -65,6 +65,8 @@ import com.google.common.cache.CacheBuilder;
*/
public abstract class ITicketService {
+ public static final String SETTING_UPDATE_DIFFSTATS = "migration.updateDiffstats";
+
private static final String LABEL = "label";
private static final String MILESTONE = "milestone";
@@ -107,6 +109,8 @@ public abstract class ITicketService {
private final Map<String, List<TicketMilestone>> milestonesCache;
+ private final boolean updateDiffstats;
+
private static class TicketKey {
final String repository;
final long ticketId;
@@ -164,6 +168,8 @@ public abstract class ITicketService {
this.labelsCache = new ConcurrentHashMap<String, List<TicketLabel>>();
this.milestonesCache = new ConcurrentHashMap<String, List<TicketMilestone>>();
+
+ this.updateDiffstats = settings.getBoolean(SETTING_UPDATE_DIFFSTATS, true);
}
/**
@@ -762,6 +768,15 @@ public abstract class ITicketService {
}
/**
+ * Returns the set of assigned ticket ids in the repository.
+ *
+ * @param repository
+ * @return a set of assigned ticket ids in the repository
+ * @since 1.6.0
+ */
+ public abstract Set<Long> getIds(RepositoryModel repository);
+
+ /**
* Assigns a new ticket id.
*
* @param repository
@@ -823,7 +838,7 @@ public abstract class ITicketService {
ticket = getTicketImpl(repository, ticketId);
// if ticket exists
if (ticket != null) {
- if (ticket.hasPatchsets()) {
+ if (ticket.hasPatchsets() && updateDiffstats) {
Repository r = repositoryManager.getRepository(repository.name);
try {
Patchset patchset = ticket.getCurrentPatchset();
@@ -856,6 +871,33 @@ public abstract class ITicketService {
*/
protected abstract TicketModel getTicketImpl(RepositoryModel repository, long ticketId);
+
+ /**
+ * Returns the journal used to build a ticket.
+ *
+ * @param repository
+ * @param ticketId
+ * @return the journal for the ticket, if it exists, otherwise null
+ * @since 1.6.0
+ */
+ public final List<Change> getJournal(RepositoryModel repository, long ticketId) {
+ if (hasTicket(repository, ticketId)) {
+ List<Change> journal = getJournalImpl(repository, ticketId);
+ return journal;
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves the ticket journal.
+ *
+ * @param repository
+ * @param ticketId
+ * @return a ticket, if it exists, otherwise null
+ * @since 1.6.0
+ */
+ protected abstract List<Change> getJournalImpl(RepositoryModel repository, long ticketId);
+
/**
* Get the ticket url
*