use of com.gitblit.models.TicketModel.Patchset in project gitblit by gitblit.
the class TicketIndexer method docToQueryResult.
/**
* Creates a query result from the Lucene document. This result is
* not a high-fidelity representation of the real ticket, but it is
* suitable for display in a table of search results.
*
* @param doc
* @return a query result
* @throws ParseException
*/
private QueryResult docToQueryResult(Document doc) throws ParseException {
QueryResult result = new QueryResult();
result.project = unpackString(doc, Lucene.project);
result.repository = unpackString(doc, Lucene.repository);
result.number = unpackLong(doc, Lucene.number);
result.createdBy = unpackString(doc, Lucene.createdby);
result.createdAt = unpackDate(doc, Lucene.created);
result.updatedBy = unpackString(doc, Lucene.updatedby);
result.updatedAt = unpackDate(doc, Lucene.updated);
result.title = unpackString(doc, Lucene.title);
result.body = unpackString(doc, Lucene.body);
result.status = Status.fromObject(unpackString(doc, Lucene.status), Status.New);
result.responsible = unpackString(doc, Lucene.responsible);
result.milestone = unpackString(doc, Lucene.milestone);
result.topic = unpackString(doc, Lucene.topic);
result.type = TicketModel.Type.fromObject(unpackString(doc, Lucene.type), TicketModel.Type.defaultType);
result.mergeSha = unpackString(doc, Lucene.mergesha);
result.mergeTo = unpackString(doc, Lucene.mergeto);
result.commentsCount = unpackInt(doc, Lucene.comments);
result.votesCount = unpackInt(doc, Lucene.votes);
result.attachments = unpackStrings(doc, Lucene.attachments);
result.labels = unpackStrings(doc, Lucene.labels);
result.participants = unpackStrings(doc, Lucene.participants);
result.watchedby = unpackStrings(doc, Lucene.watchedby);
result.mentions = unpackStrings(doc, Lucene.mentions);
result.priority = TicketModel.Priority.fromObject(unpackInt(doc, Lucene.priority), TicketModel.Priority.defaultPriority);
result.severity = TicketModel.Severity.fromObject(unpackInt(doc, Lucene.severity), TicketModel.Severity.defaultSeverity);
if (!StringUtils.isEmpty(doc.get(Lucene.patchset.name()))) {
// unpack most recent patchset
String[] values = doc.get(Lucene.patchset.name()).split(":", 5);
Patchset patchset = new Patchset();
patchset.number = Integer.parseInt(values[0]);
patchset.rev = Integer.parseInt(values[1]);
patchset.tip = values[2];
patchset.base = values[3];
patchset.commits = Integer.parseInt(values[4]);
result.patchset = patchset;
}
return result;
}
use of com.gitblit.models.TicketModel.Patchset in project gitblit by gitblit.
the class ITicketService method getTicket.
/**
* Retrieves the ticket.
*
* @param repository
* @param ticketId
* @return a ticket, if it exists, otherwise null
* @since 1.4.0
*/
public final TicketModel getTicket(RepositoryModel repository, long ticketId) {
TicketKey key = new TicketKey(repository, ticketId);
TicketModel ticket = ticketsCache.getIfPresent(key);
// if ticket not cached
if (ticket == null) {
//load ticket
ticket = getTicketImpl(repository, ticketId);
// if ticket exists
if (ticket != null) {
if (ticket.hasPatchsets() && updateDiffstats) {
Repository r = repositoryManager.getRepository(repository.name);
try {
Patchset patchset = ticket.getCurrentPatchset();
DiffStat diffStat = DiffUtils.getDiffStat(r, patchset.base, patchset.tip);
// mirroring
if (diffStat != null) {
ticket.insertions = diffStat.getInsertions();
ticket.deletions = diffStat.getDeletions();
}
} finally {
r.close();
}
}
//cache ticket
ticketsCache.put(key, ticket);
}
}
return ticket;
}
use of com.gitblit.models.TicketModel.Patchset in project gitblit by gitblit.
the class TicketServiceTest method testNotifier.
@Test
public void testNotifier() throws Exception {
Change kernel = new Change("james");
kernel.setField(Field.title, "Sample ticket");
kernel.setField(Field.body, "this **is** my sample body\n\n- I hope\n- you really\n- *really* like it");
kernel.setField(Field.status, Status.New);
kernel.setField(Field.type, Type.Proposal);
kernel.comment("this is a sample comment on a kernel change");
Patchset patchset = new Patchset();
patchset.insertions = 100;
patchset.deletions = 10;
patchset.number = 1;
patchset.rev = 25;
patchset.tip = "50f57913f816d04a16b7407134de5d8406421f37";
kernel.patchset = patchset;
TicketModel ticket = service.createTicket(getRepository(), 0L, kernel);
Change merge = new Change("james");
merge.setField(Field.mergeSha, patchset.tip);
merge.setField(Field.mergeTo, "master");
merge.setField(Field.status, Status.Merged);
ticket = service.updateTicket(getRepository(), ticket.number, merge);
ticket.repository = getRepository().name;
TicketNotifier notifier = service.createNotifier();
Mailing mailing = notifier.queueMailing(ticket);
assertNotNull(mailing);
}
Aggregations