⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ticketupdate.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        } else {
                            long owner = obj.getQw_ownerid().longValue();
                            if(owner == user.getUserID()){
                                obj.setQw_dateowned( now );    
                            }
                            else{
                                if(oldStatus != TicketHelper.ASSIGNED_STATUS){
                                    obj.setQw_status( new Integer( TicketHelper.ASSIGNED_STATUS ) );
                                    obj.setQw_dateassigned(now);
                                }
                                else{
                                    throw new EQLException( "Only owner can trigger ticket to owned status from assigned status." );
                                }
                            }
                        }
                        obj.setQw_datedelivered( null );
                        obj.setQw_resbuildversionid(null);
                        break;

                    case TicketHelper.NEW_STATUS:    
                    case TicketHelper.RELEASE_CANDIDATE_STATUS:
                    case TicketHelper.UNREPRODUCIBLE_STATUS:
                    case TicketHelper.DUPLICATE_STATUS:
                    case TicketHelper.PARKED_STATUS:
                    case TicketHelper.CLIENT_ISSUE_STATUS:
                    case TicketHelper.TESTFAIL_STATUS:
                        break;
                        
                    case TicketHelper.DELIVERED_STATUS:
                        if( obj.isNullQw_resbuildversionid() )
                            throw new EQLException( "You must fill the following field: Resolved in Build" );
                        obj.setQw_datedelivered(now);
                        break;

                    case TicketHelper.CLOSED_STATUS:
                        if( obj.isNullQw_reasoncode() )
                            throw new EQLException( "You must fill the following field: Reason Code" );
                        else{
                            if(obj.getQw_reasoncode().intValue() == TicketHelper.RC_OTHER && obj.isNullQw_otherreason())
                                throw new EQLException( "You must fill the following field: Other reason" );
                        }
                        obj.setQw_dateclosed(now);
                        // Figure the age of the call (in business hours)
                        //if( !obj.isNullDatereported() ) {
                        //    Date datereported = obj.getDatereported();
                        //    int timetoclose = ( int ) ( now.getTime() - datereported.getTime() ) / 1000;
                        //    obj.setTimetoclose( new Integer( timetoclose ) );
                        //}

                        // Now Check and set if closed on time accordingly
                        //Date mustresolveby = obj.getMustresolveby();
                        //if( mustresolveby != null && mustresolveby.getTime() < now.getTime() ) {
                        //    obj.setClosedintime( new Integer( 0 ) );
                        //} else {
                        //    obj.setClosedintime( new Integer( 1 ) );
                        //}
                        break;

                    default:
                        throw new IllegalStateException( "Unsupported ticket status: " + ticketStatus );
                }
                obj.setQw_laststatuschanged(now);
            }
            obj.setQw_modifiedbyid(new Long(user.getUserID()));
            obj.setQw_datemodified(now); 
        }
        /**
         * SetEscalationState function implementation
         */

        // The escalation state is an integer that records the current state of
        // the DB record.  This state is used by the event server to determine
        // whether an escalation should be fired.
        // The state is represented by setting bits of the integer that correspond
        // to record states.  Here, we check those record states and set bits
        // appropriately.  Note that in the case of a closed call, we want to set
        // all flags, preventing unnecessary escalations.

        boolean isClosed = false;
        int call_esc_status = 0;

        // For each state that is important to this record, set the flag
        // if the condition no longer applies

        //if( callstatus == CaseHelper.CLOSED_STATUS ) {
            // we have a closed call
        //    call_esc_status = CaseHelper.setFlag( call_esc_status,
        //                                          CaseHelper.CLOSED_STATUS );
        //    isClosed = true;
        //}

        //if( !obj.isNullWorkgroupcall() || isClosed ) {
            // we have a workgroup
        //    call_esc_status = CaseHelper.setFlag( call_esc_status,
        //                                          EscalationHelper.NOT_ASSIGNED_TYPE );
        //}

        //if( !obj.isNullOwnercall() || isClosed ) {
            // we have an owner
        //    call_esc_status = CaseHelper.setFlag( call_esc_status,
        //                                          EscalationHelper.NOT_OWNED_TYPE );
        //}

        //obj.setEscstatus( new Integer( call_esc_status ) );
        //DEBUG( "Set escstatus to: " + call_esc_status + ". Pkey: " + callID );

        /**
         * UpdateSolution function implementation
         */

        // Update the last used field of solution table

        // If there is a solution linked to thios call, and the field has changed, let's
        // increment the count on the solution that we are linked to.  We really are not
        // concerned at this point in time with decrementing the old record if there was one.

        /*if( !obj.isNullSolutioncall() && obj.isChangedSolutioncall() ) {
            long solutionId = obj.getSolutioncall().longValue();
            SolutionObjectHandler soluitionHnd = ( SolutionObjectHandler )
                SolutionObjectHandler.selectHandlerByID( jeoManager, ls, solutionId );

            SolutionObject solution = ( SolutionObject ) soluitionHnd.getJEObject();
            solution.setRefcount( new Integer( 1 ) );
            solution.setLastused( now );
            soluitionHnd.commit();
        }

        if( isNew() ) {
            obj.setDatereported( now );
        }*/

        // Reset time field
        //obj.setPhonetime( null );
        //obj.setResearchtime( null );

        if( getLogger().isInfoEnabled() ) {
            INFO( "TicketUpdate#beforeUpdate finished for ticket #" + ticketID + "." );
            INFO( "Time (ms) - " + ( System.currentTimeMillis() - time ) );
        }

        // Ok.
        return CONTINUE;

    } // beforeUpdate()
    
    
    
    /* (non-Javadoc)
     * @see EntityUpdate#beforeDelete()
     */
    public int beforeDelete()
        throws EQLException {

        long time = System.currentTimeMillis();

        // Initialization.
        JEOManagerLocal jeoManager = ( JEOManagerLocal )
            getCOM().getLocalObject( JNDINames.JEOManager, JEOManagerLocalHome.class );
        LogonSession ls = getEUO().getSession().getLogonSession();

        // Get current ticket record.
        JEObjectHandler hnd = getJEOHandler( jeoManager, TicketObjectHandler.class );
        TicketObject obj = ( TicketObject ) hnd.getJEObject();

        // Get ticket ID.
        long callID = obj.getQw_ticketid().longValue();

        // Load linked inbox messages.
        //List inboxHndList = InboxObjectHandler.selectByLinkObj( jeoManager, ls, callID, null );
        //int size = ( inboxHndList == null ) ? 0 : inboxHndList.size();
        //for( int i = 0; i < size; i++ ) {
            // Unbind inbox message.
            //InboxObjectHandler inboxHnd = ( InboxObjectHandler ) inboxHndList.get( i );
            //InboxObject inbox = ( InboxObject ) inboxHnd.getJEObject();
            //inbox.setCall_id( null );
            //inboxHnd.commit();
        //}

        if( getLogger().isInfoEnabled() ) {
            INFO( "TicketUpdate#beforeDelete finished for ticket #" + callID + "." );
            //INFO( "Unbound " + size + " inbox messages." );
            INFO( "Time (ms) - " + ( System.currentTimeMillis() - time ) );
        }

        return CONTINUE;

    } // beforeDelete()


    public void afterUpdate() throws EQLException {

        long time = System.currentTimeMillis();
        JEObjectHandler eventHnd = null;
        TicketEventObject eventObj = null;

        // Initialization.
        JEOManagerLocal jeoManager = (JEOManagerLocal)
                getCOM().getLocalObject(JNDINames.JEOManager, JEOManagerLocalHome.class);
        LogonSession ls = getEUO().getSession().getLogonSession();
        User user = ls.getUser();

        // Get current ticket record.
        JEObjectHandler hnd = getJEOHandler(jeoManager, TicketObjectHandler.class);
        TicketObject ticketObj = (TicketObject) hnd.getJEObject();
        
        
        // Send ticket notifications if status or priority changed.
        if(ticketObj.isChangedQw_status() || ticketObj.isChangedQw_priority()){
            TicketNotificationManagerLocal cnManager = getTicketNotificationManager(ls, ticketObj);
            try {
                cnManager.doNotification();
            } finally {
                try {
                    cnManager.remove();
                } catch (Throwable t) {
                }
            }
        }

        // Generate ticket escalation events.
        TicketEscalationManagerLocal teManager = getTicketEscalationManager();
        teManager.generateEvents(ls, ticketObj);
        
        // New Ticket
        if (isNew()) {
            TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.TICKET_CREATED);
        } else {
            // Status change
            if (ticketObj.isChangedQw_status())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.STATUS_CHANGE);
            // Priority change
            if (ticketObj.isChangedQw_priority())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.PRIORITY_CHANGE);
            // Impact change
            if (ticketObj.isChangedQw_impact())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.IMPACT_CHANGE);
            // Type change
            if (ticketObj.isChangedQw_type())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.TYPE_CHANGE);
            // Owner change
            if (ticketObj.isChangedQw_ownerid())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.OWNER_CHANGE);
            // Agent change
            if (ticketObj.isChangedQw_agentid())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.AGENT_CHANGE);
            // Workgroup change
            if (ticketObj.isChangedQw_workgroupid())
                TicketEventHelper.createEvent(jeoManager, ls, ticketObj, TicketEventHelper.WORKGROUP_CHANGE);
        }
    }
    
    //  private methods
    // Ticket (case) Notification Manager EJB reference getter.
    //
    private TicketNotificationManagerLocal getTicketNotificationManager(
            LogonSession ls, TicketObject ticketObj) {

        TicketNotificationManagerLocalHome home = (TicketNotificationManagerLocalHome) getCOM()
                .getLocalHome(CustomJNDINames.TicketNotificationManager,
                        TicketNotificationManagerLocalHome.class);
        try {
            return home.create(ls, ticketObj);
        } catch (CreateException ex) {
            throw new GenericSystemException(
                    "Can't get TicketNotificationManagerEJB local interface", ex);
        }
    }

    //
    // Ticket (case) Escalation Manager EJB reference getter.
    //
    private TicketEscalationManagerLocal getTicketEscalationManager() {
        INFO("Going To get TicketEscalationManagerEJB local interface");
        return (TicketEscalationManagerLocal) getCOM().getLocalObject(
                CustomJNDINames.TicketEscalationManager, TicketEscalationManagerLocalHome.class);
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -