Subversion Repositories SmartDukaan

Rev

Rev 24388 | Go to most recent revision | Details | 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
 
25
	@Autowired ActivityRepository activityRepository;
26
 
27
	@Override
28
	public void createTicket(int fofoId, int subcategoryId, String message) {
29
 
30
		ActivityType type = ActivityType.OPENED;
31
		Ticket ticket = new Ticket();
32
		ticket.setSubCategoryId(subcategoryId);
33
		ticket.setCreateTimestamp(LocalDateTime.now());
34
		try {
35
			ticket.setAssigneeId(this.getAssigneeId(subcategoryId, type));
36
		} catch (Exception e) {
37
			e.printStackTrace();
38
		}
39
		ticketRepository.persist(ticket);
40
 
41
		Activity activity = this.createActivity(type, message, 0);
42
		this.addActivity(ticket.getId(), activity);
43
 
44
		this.addActivity(ticket.getId(), activity);
45
	}
46
 
47
	private Activity createActivity(ActivityType activityType, String message, int createdBy) {
48
		Activity activity = new Activity();
49
		activity.setMessage(message);
50
		activity.setCreatedBy(createdBy);
51
		activity.setType(activityType);
52
		return activity;
53
	}
54
 
55
	private int getAssigneeId(int subcategoryId, ActivityType escalationType) throws ProfitMandiBusinessException {
56
		return 0;
57
		/*if(ActivityType.escalationTypes.contains(escalationType)) {
58
			//escalationMatrix
59
		} else {
60
			throw new ProfitMandiBusinessException("SubCategory", subcategoryId, "Could not find Assignee for ");
61
		}*/
62
	}
63
 
64
	@Override
65
	public void addActivity(int ticketId, Activity activity) {
66
		activity.setTicketId(ticketId);
67
	}
68
 
69
}