Subversion Repositories SmartDukaan

Rev

Rev 24383 | Rev 24417 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
24383 amit.gupta 1
package com.spice.profitmandi.dao.repository.cs;
2
 
3
import java.time.LocalDateTime;
4
 
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.stereotype.Component;
7
 
8
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
9
import com.spice.profitmandi.dao.entity.cs.Activity;
10
import com.spice.profitmandi.dao.entity.cs.Ticket;
11
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
12
 
13
@Component
14
public class CsServiceImpl implements CsService {
15
 
16
	@Autowired
17
	TicketRepository ticketRepository;
18
 
19
	@Autowired
20
	TicketCategoryRepository ticketCategoryRepository;
21
 
22
	@Autowired
23
	TicketSubCategoryRepository ticketSubCategoryRepository;
24
 
24388 amit.gupta 25
	@Autowired 
26
	ActivityRepository activityRepository;
24383 amit.gupta 27
 
28
	@Override
29
	public void createTicket(int fofoId, int subcategoryId, String message) {
30
 
31
		ActivityType type = ActivityType.OPENED;
32
		Ticket ticket = new Ticket();
33
		ticket.setSubCategoryId(subcategoryId);
34
		ticket.setCreateTimestamp(LocalDateTime.now());
35
		try {
36
			ticket.setAssigneeId(this.getAssigneeId(subcategoryId, type));
37
		} catch (Exception e) {
38
			e.printStackTrace();
39
		}
40
		ticketRepository.persist(ticket);
41
 
42
		Activity activity = this.createActivity(type, message, 0);
43
		this.addActivity(ticket.getId(), activity);
44
 
45
		this.addActivity(ticket.getId(), activity);
46
	}
47
 
48
	private Activity createActivity(ActivityType activityType, String message, int createdBy) {
49
		Activity activity = new Activity();
50
		activity.setMessage(message);
51
		activity.setCreatedBy(createdBy);
52
		activity.setType(activityType);
53
		return activity;
54
	}
55
 
56
	private int getAssigneeId(int subcategoryId, ActivityType escalationType) throws ProfitMandiBusinessException {
57
		return 0;
58
		/*if(ActivityType.escalationTypes.contains(escalationType)) {
59
			//escalationMatrix
60
		} else {
61
			throw new ProfitMandiBusinessException("SubCategory", subcategoryId, "Could not find Assignee for ");
62
		}*/
63
	}
64
 
65
	@Override
66
	public void addActivity(int ticketId, Activity activity) {
67
		activity.setTicketId(ticketId);
68
	}
69
 
70
}