@Override
public List<TicketModel> getTickets(RepositoryModel repository, TicketFilter filter) {
List<TicketModel> list = new ArrayList<TicketModel>();
-
- Repository db = repositoryManager.getRepository(repository.name);
- try {
- // Collect the set of all json files
- File dir = new File(db.getDirectory(), TICKETS_PATH);
- List<File> journals = findAll(dir, JOURNAL);
-
- // Deserialize each ticket and optionally filter out unwanted tickets
- for (File journal : journals) {
- String json = null;
- try {
- json = new String(FileUtils.readContent(journal), Constants.ENCODING);
- } catch (Exception e) {
- log.error(null, e);
- }
- if (StringUtils.isEmpty(json)) {
- // journal was touched but no changes were written
- continue;
- }
- try {
- // Reconstruct ticketId from the path
- // id/26/326/journal.json
- String path = FileUtils.getRelativePath(dir, journal);
- String tid = path.split("/")[1];
- long ticketId = Long.parseLong(tid);
- List<Change> changes = TicketSerializer.deserializeJournal(json);
- if (ArrayUtils.isEmpty(changes)) {
- log.warn("Empty journal for {}:{}", repository, journal);
+ List<Repository> databases = new ArrayList<Repository>();
+ List<RepositoryModel> models = new ArrayList<RepositoryModel>();
+
+ if(repository == null)
+ {
+ List<String> allRepo = repositoryManager.getRepositoryList();
+ for(int i = 0; i < allRepo.size(); i++)
+ {
+ databases.add(repositoryManager.getRepository(allRepo.get(i)));
+ models.add(repositoryManager.getRepositoryModel(allRepo.get(i)));
+ }
+ }
+ else
+ {
+ databases.add(repositoryManager.getRepository(repository.name));
+ models.add(repository);
+ }
+
+ for(int i = 0; i < databases.size(); i++)
+ {
+ Repository db = databases.get(i);
+ try {
+ // Collect the set of all json files
+ File dir = new File(db.getDirectory(), TICKETS_PATH);
+ List<File> journals = findAll(dir, JOURNAL);
+
+ // Deserialize each ticket and optionally filter out unwanted tickets
+ for (File journal : journals) {
+ String json = null;
+ try {
+ json = new String(FileUtils.readContent(journal), Constants.ENCODING);
+ } catch (Exception e) {
+ log.error(null, e);
+ }
+ if (StringUtils.isEmpty(json)) {
+ // journal was touched but no changes were written
continue;
}
- TicketModel ticket = TicketModel.buildTicket(changes);
- ticket.project = repository.projectPath;
- ticket.repository = repository.name;
- ticket.number = ticketId;
-
- // add the ticket, conditionally, to the list
- if (filter == null) {
- list.add(ticket);
- } else {
- if (filter.accept(ticket)) {
+ try {
+ // Reconstruct ticketId from the path
+ // id/26/326/journal.json
+ String path = FileUtils.getRelativePath(dir, journal);
+ String tid = path.split("/")[1];
+ long ticketId = Long.parseLong(tid);
+ List<Change> changes = TicketSerializer.deserializeJournal(json);
+ if (ArrayUtils.isEmpty(changes)) {
+ log.warn("Empty journal for {}:{}", models.get(i), journal);
+ continue;
+ }
+ TicketModel ticket = TicketModel.buildTicket(changes);
+ ticket.project = models.get(i).projectPath;
+ ticket.repository = models.get(i).name;
+ ticket.number = ticketId;
+
+ // add the ticket, conditionally, to the list
+ if (filter == null) {
list.add(ticket);
+ } else {
+ if (filter.accept(ticket)) {
+ list.add(ticket);
+ }
}
+ } catch (Exception e) {
+ log.error("failed to deserialize {}/{}\n{}",
+ new Object [] { models.get(i), journal, e.getMessage()});
+ log.error(null, e);
}
- } catch (Exception e) {
- log.error("failed to deserialize {}/{}\n{}",
- new Object [] { repository, journal, e.getMessage()});
- log.error(null, e);
}
+ } finally {
+ db.close();
}
-
- // sort the tickets by creation
- Collections.sort(list);
- return list;
- } finally {
- db.close();
}
+
+ // sort the tickets by creation
+ Collections.sort(list);
+ return list;
}
private List<File> findAll(File dir, String filename) {
* @since 1.4.0
*/
public abstract boolean hasTicket(RepositoryModel repository, long ticketId);
+
+ /**
+ * Returns all tickets. This is not a Lucene search!
+ *
+ * @return all tickets
+ */
+ public List<TicketModel> getTickets() {
+ return getTickets(null, null);
+ }
/**
* Returns all tickets. This is not a Lucene search!
*
* @param repository
- * @return all tickets
+ * @return all tickets of a given repository
* @since 1.4.0
*/
public List<TicketModel> getTickets(RepositoryModel repository) {
import com.gitblit.wicket.pages.TreePage;
import com.gitblit.wicket.pages.UserPage;
import com.gitblit.wicket.pages.UsersPage;
+import com.gitblit.wicket.pages.MyTicketsPage;
public class GitBlitWebApp extends WebApplication {
mount("/tickets/export", ExportTicketPage.class, "r", "h");
mount("/milestones/new", NewMilestonePage.class, "r");
mount("/milestones/edit", EditMilestonePage.class, "r", "h");
+ mount("/mytickets", MyTicketsPage.class, "r", "h");
// setup the markup document urls
mount("/docs", DocsPage.class, "r");
gb.notifyChangedOpenTickets = send notification for changed open tickets
gb.overdue = overdue
gb.openMilestones = open milestones
-gb.closedMilestones = closed milestones
\ No newline at end of file
+gb.closedMilestones = closed milestones
+gb.mytickets = my tickets
\ No newline at end of file
gb.serverDoesNotAcceptPatchsets = Ce serveur n'accepte pas de patchsets.
gb.ticketIsClosed = Ce ticket est clos.
gb.mergeToDescription = default integration branch for merging ticket patchsets
+gb.mytickets = mes tickets
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"
+ xml:lang="en"
+ lang="en">
+
+<body>
+ <wicket:extend>
+ <table>
+ <span>Responsible Tickets</span>
+ <tbody>
+ <tr wicket:id="responsibleTickets">
+ <td><span wicket:id="ticketName"></span></td>
+ <td><span wicket:id="ticketDescription"></span></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <table>
+ <span>Author Tickets</span>
+ <tbody>
+ <tr wicket:id="authorTickets">
+ <td><span wicket:id="ticketName"></span></td>
+ <td><span wicket:id="ticketDescription"></span></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <table>
+ <span>Voted Tickets</span>
+ <tbody>
+ <tr wicket:id="votedTickets">
+ <td><span wicket:id="ticketName"></span></td>
+ <td><span wicket:id="ticketDescription"></span></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <table>
+ <span>Watched Tickets</span>
+ <tbody>
+ <tr wicket:id="watchedTickets">
+ <td><span wicket:id="ticketName"></span></td>
+ <td><span wicket:id="ticketDescription"></span></td>
+ </tr>
+ </tbody>
+ </table>
+ </wicket:extend>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+package com.gitblit.wicket.pages;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.gitblit.models.UserModel;
+import com.gitblit.models.TicketModel;
+import com.gitblit.tickets.ITicketService;
+import com.gitblit.wicket.GitBlitWebApp;
+import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.panels.LinkPanel;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.PageParameters;
+
+public class MyTicketsPage extends RootPage {
+
+ public MyTicketsPage(PageParameters params)
+ {
+ this();
+ }
+
+ public MyTicketsPage()
+ {
+ super();
+ setupPage("", "");
+
+ UserModel currentUser = GitBlitWebSession.get().getUser();
+ if (currentUser == null) {
+ currentUser = UserModel.ANONYMOUS;
+ }
+ String username = currentUser.getName();
+
+ ITicketService tickets = GitBlitWebApp.get().tickets();
+ List<TicketModel> returnedTickets = tickets.getTickets(null);
+
+ List<TicketModel> responsibleTickets = new ArrayList<TicketModel>();
+ List<TicketModel> authorTickets = new ArrayList<TicketModel>();
+ List<TicketModel> votedTickets = new ArrayList<TicketModel>();
+ List<TicketModel> watchedTickets = new ArrayList<TicketModel>();
+ for(int i = 0; i < returnedTickets.size(); i++)
+ {
+ TicketModel ticket = returnedTickets.get(i);
+ if(ticket.isOpen())
+ {
+ if(ticket.isResponsible(username))
+ {
+ responsibleTickets.add(ticket);
+ }
+ if(ticket.isAuthor(username))
+ {
+ authorTickets.add(ticket);
+ }
+ if(ticket.isVoter(username))
+ {
+ votedTickets.add(ticket);
+ }
+ if(ticket.isWatching(username))
+ {
+ watchedTickets.add(ticket);
+ }
+ }
+ }
+
+ ListView<TicketModel> responsibleView = new ListView<TicketModel>("responsibleTickets", responsibleTickets)
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void populateItem(final ListItem<TicketModel> item)
+ {
+ final TicketModel ticket = item.getModelObject();
+ String ticketUrl = app().tickets().getTicketUrl(ticket);
+ item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl));
+ item.add(new Label("ticketDescription", ticket.body));
+ }
+ };
+
+ ListView<TicketModel> authorView = new ListView<TicketModel>("authorTickets", authorTickets)
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void populateItem(final ListItem<TicketModel> item)
+ {
+ final TicketModel ticket = item.getModelObject();
+ String ticketUrl = app().tickets().getTicketUrl(ticket);
+ item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl));
+ item.add(new Label("ticketDescription", ticket.body));
+ }
+ };
+
+ ListView<TicketModel> votedView = new ListView<TicketModel>("votedTickets", votedTickets)
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void populateItem(final ListItem<TicketModel> item)
+ {
+ final TicketModel ticket = item.getModelObject();
+ String ticketUrl = app().tickets().getTicketUrl(ticket);
+ item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl));
+ item.add(new Label("ticketDescription", ticket.body));
+ }
+ };
+
+ ListView<TicketModel> watchedView = new ListView<TicketModel>("watchedTickets", watchedTickets)
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void populateItem(final ListItem<TicketModel> item)
+ {
+ final TicketModel ticket = item.getModelObject();
+ String ticketUrl = app().tickets().getTicketUrl(ticket);
+ item.add(new LinkPanel("ticketName", "", ticket.title, ticketUrl));
+ item.add(new Label("ticketDescription", ticket.body));
+ }
+ };
+
+ add(responsibleView);
+ add(authorView);
+ add(votedView);
+ add(watchedView);
+ }
+}
pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,\r
getRootPageParameters()));\r
pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));\r
+ pages.add(new PageRegistration("gb.mytickets", MyTicketsPage.class, getRootPageParameters()));\r
if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)) {\r
pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));\r
}\r