Subversion Repositories SmartDukaan

Rev

Rev 3168 | Rev 3339 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3168 Rev 3206
Line 17... Line 17...
17
 
17
 
18
import org.apache.thrift.TException;
18
import org.apache.thrift.TException;
19
import org.springframework.context.ApplicationContext;
19
import org.springframework.context.ApplicationContext;
20
import org.springframework.context.support.ClassPathXmlApplicationContext;
20
import org.springframework.context.support.ClassPathXmlApplicationContext;
21
import org.springframework.stereotype.Service;
21
import org.springframework.stereotype.Service;
-
 
22
import org.springframework.transaction.annotation.Transactional;
22
 
23
 
23
/**
24
/**
24
 * Implementation of the interface/services exposed by thrift to clients!
25
 * Implementation of the interface/services exposed by thrift to clients!
25
 * 
26
 * 
26
 * @author mandeep
27
 * @author mandeep
Line 33... Line 34...
33
    ActivityHandler    activityHandler = context.getBean(ActivityHandler.class);
34
    ActivityHandler    activityHandler = context.getBean(ActivityHandler.class);
34
    AgentHandler       agentHandler    = context.getBean(AgentHandler.class);
35
    AgentHandler       agentHandler    = context.getBean(AgentHandler.class);
35
 
36
 
36
    public List<Ticket> getTickets(long customerId) throws TException {
37
    public List<Ticket> getTickets(long customerId) throws TException {
37
        List<Ticket> ttickets = new ArrayList<Ticket>();
38
        List<Ticket> ttickets = new ArrayList<Ticket>();
38
 
-
 
39
        for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
39
        for (in.shop2020.crm.domain.Ticket ticket : ticketHandler.getTickets(customerId)) {
40
                .getTickets(customerId)) {
-
 
41
            ttickets.add(ticket.getThriftTicket());
40
            ttickets.add(ticket.getThriftTicket());
42
        }
41
        }
43
 
42
 
44
        return ttickets;
43
        return ttickets;
45
    }
44
    }
46
 
45
 
-
 
46
    @Transactional
47
    public void updateTicket(Ticket ticket) throws TException {
47
    public void updateTicket(Ticket ticket, Activity activity) throws TException {
48
        try {
48
        try {
49
            ticketHandler.updateTicket(in.shop2020.crm.domain.Ticket
49
            ticketHandler.updateTicket(in.shop2020.crm.domain.Ticket
50
                    .create(ticket));
50
                    .create(ticket));
-
 
51
            activity.setTicketId(ticket.getId());
-
 
52
            activityHandler.insertActivity(in.shop2020.crm.domain.Activity.create(activity));
51
        } catch (ParseException e) {
53
        } catch (ParseException e) {
52
            throw new TException("Could not update " + ticket, e);
54
            throw new TException("Could not update " + ticket, e);
53
        }
55
        }
54
    }
56
    }
55
 
57
 
-
 
58
    @Transactional
56
    public long insertTicket(Ticket ticket) throws TException {
59
    public long insertTicket(Ticket ticket, Activity activity) throws TException {
57
        try {
60
        try {
58
            return ticketHandler.insertTicket(in.shop2020.crm.domain.Ticket
61
            long ticketId = ticketHandler.insertTicket(in.shop2020.crm.domain.Ticket
59
                    .create(ticket));
62
                    .create(ticket));
-
 
63
            activity.setTicketId(ticketId);
-
 
64
            activityHandler.insertActivity(in.shop2020.crm.domain.Activity.create(activity));
-
 
65
            return ticketId;
60
        } catch (ParseException e) {
66
        } catch (ParseException e) {
61
            throw new TException("Could not insert " + ticket, e);
67
            throw new TException("Could not insert " + ticket, e);
62
        }
68
        }
63
    }
69
    }
64
 
70