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

📄 formsmanager.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }        return body;    }    //    // Retrive field value from cache    // If no data found return EMPTY_VALUE    //    private String getFieldData( Entity entity, Efield field )        throws EQLException {        String fieldName = field.getName();        // get cache object        EntityData entityData = getEntityData( entity );        if( entityData == null ) {            throw new NullPointerException( "Cannot find EntityData for entity '" +                                            entity.getName() + "'" );        }        ResField resField = entityData.getResField( fieldName );        if( resField == null ) {            throw new NullPointerException( "Cannot find ResField for field '" +                                            field.getId() + "'" );        }        // get value        String value = null;        if( fieldName.equals( HistoryConstants.HISTORY_FIELD ) ) {            // field is history            if( isHtml ) {                value = getHistoryLocal().toHTML( resField.getResFieldValue() );            } else {                value = getHistoryLocal().toText( resField.getResFieldValue() );            }        } else if( field.getListref() != null ) {            // field has listfield            value = resField.getResFieldText();        } else {            // odinary field            value = resField.getResFieldValue();        }        if( StringHelper.isEmpty( value ) ) {            value = EMPTY_VALUE;        } else if( isHtml && !StringHelper.isHTML( value ) ) {            value = StringHelper.escape( value );        } else if( !isHtml && StringHelper.isHTML( value ) ) {            value = StringHelper.html2text( value );        }        return value;    }    //    // Load data for entity, cach it and return EntityData object    //    private EntityData getEntityData( Entity entity )        throws EQLException {        String entityName = entity.getName();        // try to find in cache        EntityData entityData = ( EntityData ) entityDataMap.get( entityName );        if( entityData == null ) {            // load data throw GetRecords            Properties prop = new Properties();            prop.setProperty( GRAction.IGNORE_SEND_ON_REQ_PARAM, "true" );            Ress ress = null;            try {                ress = getGetRecordsLocal().process(                    entityName,                    baseEntityName,                    new CompoundKey[] {key},                    prop,                    AccessRightsManager.getSystemLogonSession()                    ).getRess();            } catch( UserQueryParseException ex ) {                ERROR( ex );                throw ex;            }            // ...and cache result            entityData = new EntityData( ress );            entityDataMap.put( entityName, entityData );        }        return entityData;    }    //    // Get entity by the name    //    private Entity getEntity( String entityName )        throws UnknownEntityException {        try {            return getEntityViewConfigManagerLocal().getEntityViewConfig( entityName );        } catch( Exception ex ) {            if( ex instanceof UnknownEntityException ) {                throw( UnknownEntityException ) ex;            } else {                throw new UnknownEntityException( entityName );            }        }    }    //    // Get field by the name    //    private Efield getEfield( Entity entity, String fieldName )        throws UnknownEfieldException {        try {            return EntityHelper.getEfield( fieldName, entity );        } catch( UnknownEfieldException ex ) {            if( ex instanceof UnknownEfieldException ) {                throw( UnknownEfieldException ) ex;            } else {                throw new UnknownEfieldException( entity.getName(), fieldName );            }        }    }    //    // Get EntityViewConfigManager local interface    //    private EntityViewConfigManagerLocal getEntityViewConfigManagerLocal() {        return( EntityViewConfigManagerLocal )new CacheObjectManager().            getLocalObject( JNDINames.EntityViewConfigManager, EntityViewConfigManagerLocalHome.class );    }    //    // Get GetRecords local interface    //    private GetRecordsLocal getGetRecordsLocal() {        return( GetRecordsLocal )new CacheObjectManager().            getLocalObject( JNDINames.GetRecords, GetRecordsLocalHome.class );    }    //    // Get History local interface    //    private HistoryLocal getHistoryLocal() {        return( HistoryLocal )new CacheObjectManager().            getLocalObject( JNDINames.History, HistoryLocalHome.class );    }    // ------------------------------------------------------- inner class    //    // Contains cached entity data    //    private static class EntityData        implements java.io.Serializable {        private Map resFieldMap = new HashMap();        // constructor        public EntityData( Ress ress ) {            ResRecord resRecord = ress.getRes().getResRecord( 0 );            if( resRecord != null ) {                // indexing ResField objects                ResField[] resFields = resRecord.getResField();                for( int i = 0; i < resFields.length; i++ ) {                    resFieldMap.put( resFields[i].getName(), resFields[i] );                }            }        }        // get ResField object by the name        public ResField getResField( String fieldName ) {            return( ResField ) resFieldMap.get( fieldName );        }    } //-- end of inner class    //    // Body Tag Iterator    //    public static class TagIterator {        String form;        final boolean isHtml;        String entityName;        int curPos = 0;        int pos1 = 0;        int pos2 = 0;        final RE re1;        private TagIterator( String form )            throws FormTransformException {            this.form = form;            this.isHtml = StringHelper.isHTML( form );            //            // Build pattern substituion.            //            try {                if( isHtml ) {                    // HTML                    re1 = new RE( "&lt;([^ \t\n&;]*)&gt;", RE.MATCH_CASEINDEPENDENT );                } else {                    // plain text                    re1 = new RE( "<([^ \t\n><]*)>", RE.MATCH_CASEINDEPENDENT );                }            } catch( RESyntaxException ex ) {                throw new GenericSystemException( "RegExp exception: " + ex.getMessage(), ex );            }        }        boolean hasNext() {            if( form == null || form.length() <= curPos ) {                return false;            } else {                return re1.match( form, curPos );            }        }        String getNextBody()            throws FormTransformException {            try {                int startPos1 = re1.getParenStart( 0 );                int endPos1 = re1.getParenEnd( 0 );                int startOpenBracket = re1.getParenStart( 1 );                int endOpenBracket = re1.getParenEnd( 1 );                // find open element - retrive entity name                entityName = form.substring( startOpenBracket, endOpenBracket );                RE re2;                if( isHtml ) {                    re2 = new RE( "&lt;/" + entityName + "&gt;", RE.MATCH_CASEINDEPENDENT );                } else {                    re2 = new RE( "</" + entityName + ">", RE.MATCH_CASEINDEPENDENT );                }                if( !re2.match( form, endPos1 ) ) {                    // can't find close element - throw exception                    throw new FormTransformException( "Cannot find closed </" + entityName + "> tag." );                }                // we find closed element - get this block                int startPos2 = re2.getParenStart( 0 );                int endPos2 = re2.getParenEnd( 0 );                pos1 = startPos1;                pos2 = endPos2;                return form.substring( endPos1, startPos2 );            } catch( RESyntaxException ex ) {                throw new GenericSystemException( "RegExp exception: " + ex.getMessage(), ex );            }        }        // replace block        void replaceBody( String translatedBody ) {            String head = form.substring( 0, pos1 );            String tail = form.substring( pos2 );            form = head + translatedBody + tail;            curPos = pos1 + translatedBody.length();        }        void skipBody() {            curPos = pos2;        }        String getEntityName() {            return entityName;        }        String getForm() {            return form;        }    } //-- end of inner class}

⌨️ 快捷键说明

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