Subversion Repositories SmartDukaan

Rev

Rev 24383 | Rev 24417 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.repository.cs;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.dao.entity.cs.Activity;
import com.spice.profitmandi.dao.entity.cs.Ticket;
import com.spice.profitmandi.dao.entity.fofo.ActivityType;

@Component
public class CsServiceImpl implements CsService {
        
        @Autowired
        TicketRepository ticketRepository;
        
        @Autowired
        TicketCategoryRepository ticketCategoryRepository;
        
        @Autowired
        TicketSubCategoryRepository ticketSubCategoryRepository;
        
        @Autowired 
        ActivityRepository activityRepository;
        
        @Override
        public void createTicket(int fofoId, int subcategoryId, String message) {
                
                ActivityType type = ActivityType.OPENED;
                Ticket ticket = new Ticket();
                ticket.setSubCategoryId(subcategoryId);
                ticket.setCreateTimestamp(LocalDateTime.now());
                try {
                        ticket.setAssigneeId(this.getAssigneeId(subcategoryId, type));
                } catch (Exception e) {
                        e.printStackTrace();
                }
                ticketRepository.persist(ticket);
                
                Activity activity = this.createActivity(type, message, 0);
                this.addActivity(ticket.getId(), activity);
                
                this.addActivity(ticket.getId(), activity);
        }

        private Activity createActivity(ActivityType activityType, String message, int createdBy) {
                Activity activity = new Activity();
                activity.setMessage(message);
                activity.setCreatedBy(createdBy);
                activity.setType(activityType);
                return activity;
        }
        
        private int getAssigneeId(int subcategoryId, ActivityType escalationType) throws ProfitMandiBusinessException {
                return 0;
                /*if(ActivityType.escalationTypes.contains(escalationType)) {
                        //escalationMatrix
                } else {
                        throw new ProfitMandiBusinessException("SubCategory", subcategoryId, "Could not find Assignee for ");
                }*/
        }

        @Override
        public void addActivity(int ticketId, Activity activity) {
                activity.setTicketId(ticketId);
        }

}