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

📄 jeobjecthandler.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            value = null;        } else if( methodName.startsWith( "_set" ) ) {            // Special field value setter (use it to update external memo).            //   arg[0] - new listfield value            //   return void            checkIsValid();            EQLResCell resCell = getEQLResCell( methodName, 4, true );            // Set list field value.            setListFieldValue( resCell, resCell.getListField(), EQLObject.getInstance( args[0] ) );            // Value changed!            resCell.forceChanged();            value = null;        } else if( methodName.startsWith( "ds" ) ) {            // Dataset getter.            //   arg[0] - dataset hnd class            //   return List of dataset handlers            EQLDRes dRes = getEQLDRes( methodName, 2 );            Class hndClass = ( Class ) args[0];            String datasetName = dRes.getReqDataset().getDataset().getName();            // try find in map            value = dsJEOHndListMap.get( datasetName );            if( value == null ) {                // .. create new hnd list                value = new DatasetJEOHndList( dRes, hndClass );                dsJEOHndListMap.put( datasetName, value );            }        } else {            // Unknown method.            throw new GenericSystemException( "Unsupported method '" + methodName + "'" );        }        // Ok.        if( debug ) {            DEBUG( "Method returned '" + value + "', entity - '" + getEntity().getName() + "'" );        }        return value;    }    // ========================================================= Protected methods    /**     * Helper method that returns the JEO instance from <tt>hnd</tt> JEO handler     * casted to the type represented by <tt>clazz</tt> class.     *      * @throws ClassCastException if the JEO instance is not null     * and is not assignable to the type T.     */    protected final static <T extends JEObject> T getJEObject(JEObjectHandler hnd, Class<T> clazz) {        return hnd != null ? hnd.getJEObject(clazz) : null;    }    /**     * Helper method that returns a collection of the JEO instances from <tt>hndList</tt> collection of JEO handlers     * casted to the type represented by <tt>clazz</tt> class.     *      * @throws ClassCastException if the JEO instance is not null     * and is not assignable to the type T.     */    protected final static <T extends JEObject> List<T> getJEObjectList(List hndList, Class<T> clazz) {        if (hndList == null)            return Collections.emptyList();                List<T> list = new ArrayList<T>();        for (Iterator it = hndList.iterator(); it.hasNext();) {            JEObjectHandler hnd = (JEObjectHandler) it.next();            if(hnd != null)                list.add(hnd.getJEObject(clazz));        }        return Collections.unmodifiableList(list);    }    // ========================================================= Private methods    // Gets EQLResCell by the JEO object method name.    // If forceInsert = true and EQLResCell is null -> create empty    private EQLResCell getEQLResCell( String methodName, int prefixSize, boolean forceInsert ) {        Entity entity = getEntity();        String fieldName = methodName.substring( prefixSize ).toLowerCase();        Efield field = EntityHelper.getEfield( fieldName, entity );        EQLReqField reqField = new EQLReqField( entity, field );        EQLResCell resCell = eqlResRecord.getResCell( reqField );        if( resCell == null ) {            if( forceInsert ) {                DEBUG( "Insert new null cell: " + reqField );                resCell = new EQLResCell( reqField, true );                eqlResRecord.insertData( resCell );            } else {                ERROR( "Incorrect method '" + methodName + "'." );                ERROR( "	eqlResRecord: " + eqlResRecord );                throw new NullPointerException( "Can't find appropriate EQLResCell object for method  '" +                                                methodName + "'. Entity: " + entity.getName() +                                                ". Field: " + fieldName + "." );            }        }        return resCell;    }    // Gets EQLDRes by the JEO object method name.    private EQLDRes getEQLDRes( String methodName, int prefixSize ) {        Entity entity = getEntity();        String datasetName = methodName.substring( prefixSize ).toLowerCase();        Dataset dataset = EntityHelper.getDataset( datasetName, entity );        Entity datasetEntity = getEntityViewConfigManagerLocal().getEntityViewConfig( dataset.getEntity() );        EQLReqDataset reqDataset = new EQLReqDataset( entity, dataset, datasetEntity );        EQLDRes dRes = eqlResRecord.getDRes( reqDataset );        if( dRes == null ) {            ERROR( "Incorrect method '" + methodName + "'." );            ERROR( "	eqlResRecord: " + eqlResRecord );            throw new NullPointerException( "Can't find appropriate EQLDRes object for method  '" +                                            methodName + "'. Entity: " + entity.getName() +                                            ". Dataset: " + datasetName + "." );        }        return dRes;    }    /**     * Set list field value to changed field     * @param resCell EQLResCell object of changed field     * @param listResCell EQLResCell list ref object of changed field     * @param listObj EQLObject list ref value (optional)     * @throws EQLException     */    private void setListFieldValue( EQLResCell resCell,                                    EQLResCell listResCell,                                    EQLObject listObj )        throws EQLException {        Listref lref = resCell.getReqField().getField().getListref();        if( lref == null ) {            // No list field found - skip process.            return;        }        if( listResCell == null ) {            // Create new empty list EQLResCell object.            Entity listEntity = getEntityViewConfigManagerLocal().getEntityViewConfig( lref.getEntity() );            Efield listField = EntityHelper.getEfield( lref.getEfield(), listEntity );            EQLReqField listReqField = new EQLReqField( listEntity, listField );            listResCell = new EQLResCell( listReqField, true );            resCell.addListField( listResCell );        }        // Set value.        if( listObj == null ) {            listObj = EQLUtils.getListFieldValue( eqlResRecord, resCell, listResCell.getReqField(), true, ls, getEQLManagerLocal() );        }        listResCell.setEQLObject( listObj );    }    // Entity View Config Manager EJB reference getter.    private EntityViewConfigManagerLocal getEntityViewConfigManagerLocal() {        return( EntityViewConfigManagerLocal )new CacheObjectManager().            getLocalObject( JNDINames.EntityViewConfigManager, EntityViewConfigManagerLocalHome.class );    }    // EQL Manager EJB reference getter.    private EQLManagerLocal getEQLManagerLocal() {        return( EQLManagerLocal )new CacheObjectManager().            getLocalObject( JNDINames.EQLManager, EQLManagerLocalHome.class );    }    // JEO Manager EJB reference getter.    private JEOManagerLocal getJEOManagerLocal() {        return( JEOManagerLocal )new CacheObjectManager().            getLocalObject( JNDINames.JEOManager, JEOManagerLocalHome.class );    }    // ========================================================= Inner class    /**     * List of dataset JEO handlers     * Some methods are not implemented.     * <p>@author [ALB] Baranov Andrey</p>     */    public class DatasetJEOHndList        implements List, Serializable {        private EQLDRes dRes;        private Class hndClass;        private List hndList;        /**         * Constructor         * @param dRes EQLDRes object         * @param hndClass dataset handler class         */        public DatasetJEOHndList( EQLDRes dRes, Class hndClass ) {            this.dRes = dRes;            this.hndClass = hndClass;            this.hndList = new ArrayList();            for( int i = 0; i < dRes.size(); i++ ) {                addHnd( dRes.getRecord( i ) );            }        }        /**         * Add dataset handler         * @param dsResRecord EQLResRecord object         */        public void addHnd( EQLResRecord dsResRecord ) {            JEObjectHandler dsHnd = getJEOManagerLocal().getJEO( ls, dRes, dsResRecord, hndClass );            hndList.add( dsHnd );        }        // ------------------------------------------------- list interface methods        public Object get( int index ) {            return hndList.get( index );        }        public boolean add( Object o ) {            if( ! ( o instanceof JEObjectHandler ) ) {                throw new IllegalStateException();            }            JEObjectHandler hnd = ( JEObjectHandler ) o;            boolean added = hndList.add( hnd );            if( added ) {                dRes.addRecord( hnd.eqlResRecord );            }            return added;        }        public void add( int index, Object o ) {            throw new UnsupportedOperationException();        }        public boolean addAll( Collection c ) {            throw new UnsupportedOperationException();        }        public boolean addAll( int index, Collection c ) {            throw new UnsupportedOperationException();        }        public Object set( int index, Object element ) {            throw new UnsupportedOperationException();        }        public Iterator iterator() {            throw new UnsupportedOperationException();        }        public ListIterator listIterator() {            throw new UnsupportedOperationException();        }        public ListIterator listIterator( int index ) {            throw new UnsupportedOperationException();        }        public int size() {            return hndList.size();        }        public boolean remove( Object o ) {            if( ! ( o instanceof JEObjectHandler ) ) {                throw new IllegalStateException();            }            JEObjectHandler hnd = ( JEObjectHandler ) o;            boolean removed = hndList.remove( hnd );            if( removed ) {                dRes.removeRecord( hnd.eqlResRecord );            }            return removed;        }        public Object remove( int index ) {            throw new UnsupportedOperationException();        }        public boolean removeAll( Collection c ) {            throw new UnsupportedOperationException();        }        public boolean retainAll( Collection c ) {            throw new UnsupportedOperationException();        }        public void clear() {            /** @todo implement it */            hndList.clear();        }        public boolean contains( Object o ) {            return hndList.contains( o );        }        public boolean containsAll( Collection c ) {            return hndList.containsAll( c );        }        public int indexOf( Object o ) {            return hndList.indexOf( o );        }        public int lastIndexOf( Object o ) {            return hndList.lastIndexOf( o );        }        public boolean isEmpty() {            return hndList.isEmpty();        }        public List subList( int fromIndex, int toIndex ) {            throw new UnsupportedOperationException();        }        public Object[] toArray() {            return hndList.toArray();        }        public Object[] toArray( Object[] a ) {            return hndList.toArray( a );        }    }}

⌨️ 快捷键说明

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