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

📄 historybuildergenericimpl.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                            }                        }                        if( value != null ) {                            fld = new HistoryField();                            fld.setName( efield.getName() );                            fld.setCaption( getFieldCaption( entity, efield ) );                            fld.setHistoryValueOld( value );                            fld.setHistoryValueNew( new String( value ) );                        }                    } else {                        fld = getHistoryField( j, rRecord, dsLogFieldNames );                    }                    if( fld != null ) {                        ifgRecord.addHistoryField( fld );                    }                }                if( ifgRecord.getHistoryFieldCount() > 0 ) {                    ifg.addIfgRecord( ifgRecord );                }            }            if( ( ifg != null ) && ( ifg.getIfgRecordCount() > 0 ) ) {                ifgData.addIfg( ifg );            }        } // for        topic.setHistoryData( data );        topic.setIfgData( ifgData );        // Ok.        return topic;    }    /* (non-javadoc)     * @see HistoryBuilder#getLogFieldNames     */    public List getLogFieldNames( String dbObject ) {        List fieldNames = new ArrayList();        JEOManagerLocal jeoManager = getJEOManager();        List hndList = null;        try {            hndList = HistoryTableFieldObjectHandler.selectByTableName( jeoManager, ls, dbObject );        } catch( EQLException ex ) {            throw new GenericSystemException( ex );        }        if( hndList != null ) {            for( int i = 0; i < hndList.size(); i++ ) {                HistoryTableFieldObjectHandler hnd = ( HistoryTableFieldObjectHandler ) hndList.get( i );                HistoryTableFieldObject o = ( HistoryTableFieldObject ) hnd.getJEObject();                fieldNames.add( o.getHis_field_name() );            }        }        return( fieldNames.size() == 0 ) ? null : fieldNames;    }    // ======================================================== Private methods    //    // Makes a HistoryField object with old and new values of a field from i-th resCell of resRecord.    //    private HistoryField getHistoryField( int i, EQLResRecord resRecord, List historyFieldNames ) {        // Get EQL data cell.        EQLResCell resCell = resRecord.getResCell( i );        if( !resCell.isValueChanged() ) {            return null;        }        // Get EQL objects for old and new field values.        Entity entity = resCell.getReqField().getReqEntity().getEntity();        Efield efield = resCell.getReqField().getField();        EQLObject newObj = resCell.getEQLObject();        EQLObject oldObj = resCell.getOldEQLObject();        // Is this field must be logged?        if( !historyFieldNames.contains( efield.getName() ) ) {            return null;        }        // Is its value changed?        if( newObj.equals( oldObj ) ) {            return null;        }        // Transform field, if it's not a link to another entity.        String newValue, oldValue;        if( efield.getListref() != null ) {            try {                newValue = EQLUtils.getListFieldValue( resRecord, resCell, resCell.getListField().getReqField(), true, ls, getEQLManager() ).toString();                oldValue = EQLUtils.getListFieldValue( resRecord, resCell, resCell.getListField().getReqField(), false, ls, getEQLManager() ).toString();            } catch( EQLException ex ) {                throw new GenericSystemException( ex );            }        } else {            try {                newValue = FieldConverter.EQLObject2String( ls, entity, efield, newObj );                oldValue = FieldConverter.EQLObject2String( ls, entity, efield, oldObj );            } catch( EfieldTransformException ex ) {                throw new GenericSystemException( ex );            }        }        // Convert null values into empty strings.        newValue = ( newValue == null ? StringHelper.EMPTY_VALUE : newValue );        oldValue = ( oldValue == null ? StringHelper.EMPTY_VALUE : oldValue );        // Make the field object.        HistoryField field = new HistoryField();        field.setName( efield.getName() );        field.setCaption( getFieldCaption( entity, efield ) );        field.setHistoryValueNew( newValue );        field.setHistoryValueOld( oldValue );        return field;    }    //    // Returns a record from the list of record where the first resCell is equal to the first resCell of resRecord.    //    private EQLResRecord getAdditRecord( List records, EQLResRecord resRecord ) {        for( Iterator itr = records.iterator(); itr.hasNext(); ) {            EQLResRecord record = ( EQLResRecord ) itr.next();            if( ( ( !record.doDelete() ) && ( !record.doUpdate() ) && ( !record.isNew() ) )                && ( ( resRecord.getResCell( 0 ).getReqField().equals( record.getResCell( 0 ).getReqField() ) )                     && ( resRecord.getResCell( 0 ).getEQLObject().equals( record.getResCell( 0 ).getEQLObject() ) ) ) ) {                return record;            }        }        return resRecord;    }    //    // Field caption.    //    private String getFieldCaption( Entity entity, Efield field ) {        String langID = ls.getUser().getLangID();        String entityName = entity.getName();        String efieldName = field.getName();        CustomField customField = getCustomConfigManager()            .getLocalizedCustomField( langID, entityName, efieldName );        if( customField == null ) {            return "<" + field.getId() + ">";        } else {            return customField.getCaption();        }    }    //    // Gets the current date (formatted for the active user).    //    private String getHistoryTimestapm() {        User user = getSession().getLogonSession().getUser();        String datePattern = user.getDatePattern();        String timePattern = user.getTimePattern();        boolean isDatePosFirst = user.isDatePositionFirst();        Locale locale = SecurityHelper.getJavaLocale(user.getCountryID(), user.getLangID());        TimeZone tz = SecurityHelper.getJavaTimezone(user.getTimeZoneID());        Date now = new Date( DateHelper.toUser( DateHelper.currentTimeMillis(), tz ) );        return DateHelper.formatDate( now, datePattern, timePattern, locale );    }    // ============================================================ EJB getters    // EQL Manager EJB reference getter.    private EQLManagerLocal getEQLManager() {        return( EQLManagerLocal ) getSession().getCOM().            getLocalObject( JNDINames.EQLManager, EQLManagerLocalHome.class );    }    // Custom Config Manager EJB reference getter.    private CustomConfigManagerLocal getCustomConfigManager() {        return( CustomConfigManagerLocal ) getSession().getCOM().            getLocalObject( JNDINames.CustomConfigManager, CustomConfigManagerLocalHome.class );    }    // JEOManager EJB reference getter.    private JEOManagerLocal getJEOManager() {        return( JEOManagerLocal ) getSession().getCOM().            getLocalObject( JNDINames.JEOManager, JEOManagerLocalHome.class );    }}

⌨️ 快捷键说明

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