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

📄 alerteqlagent.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        // 10) recipient_type        cell = getNumberCell( entity, "recipient_type", alert.getRecipientType() );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "recipient_type" ) );        }        // 11) workgroup_id        cell = getNumberCell( entity, "workgroup_id", alert.getWorkgroupID() );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "workgroup_id" ) );            if( alert.getWorkgroupID() != null ) {                _addWorkgroupListCell( eqlSession, cell, alert.getWorkgroupID().longValue() );            }        }        // 12) tier        cell = getNumberCell( entity, "tier", alert.getTier() );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "tier" ) );        }        // 13) to_all        cell = getBooleanCell( entity, "to_all", Boolean.valueOf( alert.isToAll() ) );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "to_all" ) );        }        // 14) focus_id        cell = getStringCell( entity, "focus_id", ( alertData != null ) ? alertData.getFocusID() : null );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "focus_id" ) );        }        // 15) tab_id        cell = getStringCell( entity, "tab_id", ( alertData != null ) ? alertData.getTabID() : null );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "tab_id" ) );        }        // 16) form_id        cell = getStringCell( entity, "form_id", ( alertData != null ) ? alertData.getFormID() : null );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "form_id" ) );        }        // 17) record_id        cell = getStringCell( entity, "record_id", ( recordKey != null ) ? ( String ) recordKey.getKey( 0 ) : null );        if( cell != null ) {            record.addData( cell, columNames.indexOf( "record_id" ) );        }        // 18) record_id2        // 19) record_id3        // 20) record_id4        int keys = ( recordKey != null ) ? recordKey.size() : 0;        for( int i = 1; i < 4; i++ ) {            cell = getStringCell( entity, "record_id" + ( i + 1 ), ( i < keys ) ? ( String ) recordKey.getKey( i ) : null );            if( cell != null ) {                record.addData( cell, columNames.indexOf( "record_id" + ( i + 1 ) ) );            }        }    }    //    // Fulfil insert operation    //    protected int __doInsert( EQLSession eqlSession, EQLERes res, EQLResRecord resRecord )        throws EQLException {        // Read params.        // 1) alert_id        Entity entity = res.getEntity();        EQLResCell resCell = resRecord.getResCell( getReqField( entity, "alert_id" ) );        Long alertID = ( resCell != null ) ? resCell.getLong() : null;        // 2) creator_id        resCell = resRecord.getResCell( getReqField( entity, "creator_id" ) );        Long creatorID = ( resCell != null ) ? resCell.getLong() : null;        Integer creatorType = null;        if( creatorID != null ) {            // 3) creator_type            resCell = resRecord.getResCell( getReqField( entity, "creator_type" ) );            creatorType = ( resCell != null ) ? resCell.getInteger() : null;            if( creatorType == null ) {                throwUserQueryParseException( eqlSession, res, "creator_type", null, null );            }        }        // 4) sender_id        resCell = resRecord.getResCell( getReqField( entity, "sender_id" ) );        Long senderID = ( resCell != null ) ? resCell.getLong() : null;        Integer senderType = null;        if( senderID != null ) {            // 5) sender_type            resCell = resRecord.getResCell( getReqField( entity, "sender_type" ) );            senderType = ( resCell != null ) ? resCell.getInteger() : null;            if( senderType == null ) {                throwUserQueryParseException( eqlSession, res, "sender_type", null, null );            }        }        // 6) message        resCell = resRecord.getResCell( getReqField( entity, "message" ) );        String message = ( resCell != null ) ? resCell.getString() : null;        if( message == null ) {            throwUserQueryParseException( eqlSession, res, "message", null, null );        }        // 7) severity        resCell = resRecord.getResCell( getReqField( entity, "severity" ) );        Integer severity = ( resCell != null ) ? resCell.getInteger() : null;        if( severity == null ) {            throwUserQueryParseException( eqlSession, res, "severity", null, null );        }        // 8) dateposted        resCell = resRecord.getResCell( getReqField( entity, "dateposted" ) );        Date dateposted = ( resCell != null ) ? resCell.getDate() : null;        // 9) recipient_id        Long recipientID = null;        resCell = resRecord.getResCell( getReqField( entity, "recipient_id" ) );        recipientID = ( resCell != null ) ? resCell.getLong() : null;        Integer recipientType = null;        if( recipientID != null ) {            // 10) recipient_type            resCell = resRecord.getResCell( getReqField( entity, "recipient_type" ) );            recipientType = ( resCell != null ) ? resCell.getInteger() : null;        }        Long workgroupID = null;        Integer tier = null;        if( recipientID == null ) {            // 11) workgroup_id            resCell = resRecord.getResCell( getReqField( entity, "workgroup_id" ) );            workgroupID = ( resCell != null ) ? resCell.getLong() : null;            if( workgroupID != null ) {                // 12) tier                resCell = resRecord.getResCell( getReqField( entity, "tier" ) );                tier = ( resCell != null ) ? resCell.getInteger() : null;            }        }        // 13) to_all        resCell = resRecord.getResCell( getReqField( entity, "to_all" ) );        Integer i = ( resCell != null ) ? resCell.getInteger() : null;        boolean toAll = ( i != null ) ? ( i.intValue() == 1 ) : false;        if( !toAll && recipientID == null && workgroupID == null ) {            throwUserQueryParseException( eqlSession, res, "to_all", null,                                          "Either user, workgroup or 'To All' must be specified" );        }        // 14) focus_id        resCell = resRecord.getResCell( getReqField( entity, "focus_id" ) );        String focusID = ( resCell != null ) ? resCell.getString() : null;        AlertData data = null;        if( focusID != null ) {            // 15) tab_id            resCell = resRecord.getResCell( getReqField( entity, "tab_id" ) );            String tabID = ( resCell != null ) ? resCell.getString() : null;            // 16) form_id            resCell = resRecord.getResCell( getReqField( entity, "form_id" ) );            String formID = ( resCell != null ) ? resCell.getString() : null;            // 17) record_id            resCell = resRecord.getResCell( getReqField( entity, "record_id" ) );            String recordID = ( resCell != null ) ? resCell.getString() : null;            // 18) record_id2            resCell = resRecord.getResCell( getReqField( entity, "record_id2" ) );            String recordID2 = ( resCell != null ) ? resCell.getString() : null;            // 19) record_id3            resCell = resRecord.getResCell( getReqField( entity, "record_id3" ) );            String recordID3 = ( resCell != null ) ? resCell.getString() : null;            // 20) record_id4            resCell = resRecord.getResCell( getReqField( entity, "record_id4" ) );            String recordID4 = ( resCell != null ) ? resCell.getString() : null;            // Init AlertData.            CompoundKey recordKey = new CompoundKey();            if( recordID != null ) {                recordKey.addKey( recordID );            }            if( recordID2 != null ) {                recordKey.addKey( recordID2 );            }            if( recordID3 != null ) {                recordKey.addKey( recordID3 );            }            if( recordID4 != null ) {                recordKey.addKey( recordID4 );            }            data = new AlertData( focusID, tabID, formID, recordKey );        }        AlertManagerLocal local = null;        long[] ret;        try {            // Get local reference.            local = getAlertManagerLocal( eqlSession, message, severity.intValue() );            // Set optional attributes.            if( alertID != null ) {                local.setId( alertID.longValue() );            }            if( creatorID != null ) {                local.setCreator( creatorID.longValue(), creatorType.intValue() );            }            if( senderID != null ) {                local.setSender( senderID.longValue(), senderType.intValue() );            }            if( dateposted != null ) {                local.setDateposted( dateposted );            }            if( data != null ) {                local.setData( data );            }            // Call Alert Manager            if( recipientID != null ) {                ret = local.sendAlert( recipientID.longValue(), recipientType.intValue() );            } else if( workgroupID != null ) {                ret = local.sendAlerts( workgroupID.longValue(), tier, toAll );            } else {                ret = local.sendAlert();            }        } finally {            try {                if( local != null ) {                    local.remove();                }            } catch( Exception ex ) {}        }        // Ok.        return( ret != null ) ? ret.length : 0;    }    //    // Fulfil update operation    //    protected int __doUpdate( EQLSession eqlSession, EQLERes res, EQLResRecord resRecord )        throws EQLException {        // Read params.        // WARINING: Support update only for message and severity.        // 1) alert_id        Entity entity = res.getEntity();        EQLResCell resCell = resRecord.getResCell( getReqField( entity, "alert_id" ) );        Long alertID = ( resCell != null ) ? resCell.getLong() : null;        if( alertID == null ) {            throwUserQueryParseException( eqlSession, res, "alert_id", null, null );        }        // 2) message        resCell = resRecord.getResCell( getReqField( entity, "message" ) );        String message = ( resCell != null ) ? resCell.getString() : null;        if( message == null ) {            throwUserQueryParseException( eqlSession, res, "message", null, null );        }        // 3) severity        resCell = resRecord.getResCell( getReqField( entity, "severity" ) );        Integer severity = ( resCell != null ) ? resCell.getInteger() : null;        if( severity == null ) {            throwUserQueryParseException( eqlSession, res, "severity", null, null );        }        AlertManagerLocal local = null;        long[] ret;        try {            // Get local reference.            local = getAlertManagerLocal( eqlSession, message, severity.intValue() );            // Set ID.            local.setId( alertID.longValue() );            // Call Alert Manager            ret = local.updateAlert();        } finally {            try {                if( local != null ) {                    local.remove();                }            } catch( Exception ex ) {}        }        // Ok.        return( ret != null ) ? ret.length : 0;    }    //    // Get AlertManager local interface    //    protected AlertManagerLocal getAlertManagerLocal( EQLSession eqlSession ) {        AlertManagerLocalHome home = ( AlertManagerLocalHome ) eqlSession.getCOM().            getLocalHome( JNDINames.AlertManager, AlertManagerLocalHome.class );        try {            return home.create( eqlSession.getLogonSession() );        } catch( CreateException ex ) {            throw new GenericSystemException( "Can't create AlertManager EJB.", ex );        }    }    //    // Adds List EQLResCell for user-like EQLResCell.    //    protected void _addUserListCell( EQLSession eqlSession,                                     EQLResCell cell,                                     long userID,                                     int userType ) {        try {            User user = AccessRightsManager.getUser( userID );            EQLResCell listCell = getStringListCell( eqlSession, cell, user.getFullName() );            if( listCell != null ) {                cell.addListField( listCell );            }        } catch( NoSuchUserException ex ) {            logger.WARN( ex.getMessage() );        }    }    //    // Adds List EQLResCell for workgroup-like EQLResCell.    //    protected void _addWorkgroupListCell( EQLSession eqlSession,                                          EQLResCell cell,                                          long wgID ) {        try {            WorkGroup wg = AccessRightsManager.getGroup( wgID );            EQLResCell listCell = getStringListCell( eqlSession, cell, wg.getGroupName() );            if( listCell != null ) {                cell.addListField( listCell );            }        } catch( NoSuchGroupException ex ) {            logger.WARN( ex.getMessage() );        }    }    //    // Adds List EQLResCell for severity EQLResCell.    //    protected void _addSeverityListCell( EQLSession eqlSession,                                         EQLResRecord record,                                         EQLResCell cell )        throws EQLException {        Object key = cell.getEQLObject().getObject();        // Check in Map first.        EQLResCell listCell = null;        EQLObject listObj = ( EQLObject ) severityMap.get( key );        if( listObj != null ) {            logger.DEBUG( "Found severity in the cache: " + listObj );            EQLReqField listReqField = getListReqField( eqlSession, cell.getReqField().getField() );            if( listReqField != null ) {                listCell = new EQLResCell( listReqField, listObj );            }        } else {            listCell = getListResCell( eqlSession, record, cell );            // Put to the cache.            severityMap.put( key, listCell.getEQLObject() );        }        if( listCell != null ) {            cell.addListField( listCell );        }    }    //    // Get AlertManager local interface    //    protected AlertManagerLocal        getAlertManagerLocal( EQLSession eqlSession,                              String message,                              int severityId ) {        AlertManagerLocalHome home = ( AlertManagerLocalHome ) eqlSession.getCOM().            getLocalHome( JNDINames.AlertManager, AlertManagerLocalHome.class );        try {            return home.create( message, severityId, eqlSession.getLogonSession() );        } catch( CreateException ex ) {            throw new GenericSystemException( "Can't create AlertManager EJB.", ex );        }    }}

⌨️ 快捷键说明

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