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

📄 historyejb.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                history += existingHistory;                hisObj.setQx_history(history.toCharArray());                hisObj.setQx_datemodified(DateHelper.getNowDate());                hisHnd.commit();            } else {                // User handler and object                 JEObjectHandler hnd = jeoManager.create( ls, HistoryObjectHandler.class );                HistoryObject hisObj = ( HistoryObject ) hnd.getJEObject();                hisObj.setQx_history(history.toCharArray());                hisObj.setQx_object(dbObject);                hisObj.setQx_objectid(pkeyId);                hisObj.setQx_datemodified(DateHelper.getNowDate());                hnd.commit();                historyId = hisObj.getQx_historyid();            }        } catch( Throwable tr ) {            ErrorHelper.throwSystemException( tr, this );        }        return historyId;    }    /**     * Writes the changes history.     *     * @param session EQL session     * @param resRecord given EQL response record     * @param fieldNames names of fields that might be logged     * @param dbObject table name     * @param pkeyId value of the pkey field     * @throws EQLException     */    public void storeHistoryByObj( EQLSession session, EQLResRecord resRecord, List fieldNames, String dbObject, Long pkeyId )        throws EQLException {        try {            // Make a new history topic.            HistoryTopic historyTopic = createHistoryTopic( session, resRecord, fieldNames );            /* Escape history saving, if all histories are empty*/            if((historyTopic.getHistoryData() == null || historyTopic.getHistoryData().getHistoryFieldCount() == 0) &&                    (historyTopic.getIfgData() == null || historyTopic.getIfgData().getIfgCount() == 0)) {                return;            }            // History topic -> string            String history = toString( historyTopic );            DEBUG(history);            // Initialization.            LogonSession ls = session.getLogonSession();            JEOManagerLocal jeoManager = ( JEOManagerLocal ) session.getCOM().                getLocalObject( JNDINames.JEOManager, JEOManagerLocalHome.class );                        HistoryObjectHandler hisHnd = ( HistoryObjectHandler )            HistoryObjectHandler.selectByObj( jeoManager, ls, dbObject, pkeyId.longValue() );            if( hisHnd == null ) {            // Creating a new history topic.                JEObjectHandler hnd = jeoManager.create( ls, HistoryObjectHandler.class );                HistoryObject hisObj = ( HistoryObject ) hnd.getJEObject();                hisObj.setQx_history(history.toCharArray());                hisObj.setQx_object(dbObject);                hisObj.setQx_objectid(pkeyId);                hisObj.setQx_datemodified(DateHelper.getNowDate());                hnd.commit();            } else {            // Add the topic to an existing history.                HistoryObject hisObj = ( HistoryObject ) hisHnd.getJEObject();                char[] memo = hisObj.getQx_history();                String existingHistory = String.valueOf( memo );                // If the existing history is invalid, leave it unparsed.                if( !isHistoryValid( existingHistory ) ) {                    HistoryUnparsedTopic unparsedTopic = new HistoryUnparsedTopic();                    unparsedTopic.setHistoryUnparsedData( StringHelper.escape( existingHistory ) );                    existingHistory = toString( unparsedTopic );                }                history += existingHistory;                hisObj.setQx_history(history.toCharArray());                hisObj.setQx_datemodified(DateHelper.getNowDate());                hisHnd.commit();            }        } catch( Throwable tr ) {            ErrorHelper.throwSystemException( tr, this );        }    }    /**     * Returns the history log as an HTML document.     * @param history history log     * @return HTML document     */    public String toHTML( String history ) {        DEBUG( "Making the history log HTML view..." );        if(StringHelper.isEmpty(history)) {            return history;        }        String html;        try {            html = transform( history, HistoryConstants.HISTORY_HTML_TRANSLET );        } catch( Exception ex ) {            ERROR( ex );            html = getAsCDATA( history );        }        DEBUG( "\n\n\t XML data: \n\n" + history + "\n\n" );        DEBUG( "\n\n\t HTML data: \n\n" + html + "\n\n" );        return html;    }    /**     * Returns the history log as a text document.     * @param history history log     * @return text document     */    public String toText( String history ) {        DEBUG( "Making the history log text view..." );        if(StringHelper.isEmpty(history)) {            return history;        }        String text;        try {            text = transform( history, HistoryConstants.HISTORY_TEXT_TRANSLET );        } catch( Exception ex ) {            ERROR( ex );            text = history;        }        DEBUG( "\n\n\t XML data: \n\n" + history + "\n\n" );        DEBUG( "\n\n\t Text data: \n\n" + text + "\n\n" );        return text;    }    /**     * Checks history XML (really checks for <history-topic> tag).     * @param history the history topic to check     * @return true if valid     */    public boolean isHistoryValid( String history ) {        if( history == null ) {            return true;        }        int pos = history.indexOf( HistoryConstants.HISTORY_TOPIC_TAG );        return( pos >= 0 );    }    // ========================================================= Private methods    // Gets the names of fields that might be logged.    private List getLogFieldNames(  EQLSession session, String dbObject ) {        EQLFactory factory = EQLFactory.getInstance();        return factory.getHistoryBuilder( session ).getLogFieldNames(dbObject);    }    // Creates a new history topic.    private HistoryTopic createHistoryTopic( EQLSession session,                                             EQLResRecord resRecord,                                             List fieldNames ) {        EQLFactory factory = EQLFactory.getInstance();        return factory.getHistoryBuilder( session ).createHistoryTopic( resRecord, fieldNames );    }    // Converts the XML object to string.    private String toString( Object o ) {        char[] data = XMLHelper.writeObject( o );        String s = String.valueOf( data );        // Remove <?xml ...?> string and 'bad' characters.        return StringHelper.clearXml( s );    }    // Puts the given string into the CDATA section.    private String getAsCDATA( String s ) {        StringBuffer sb = new StringBuffer();        sb.append( "<html>" );        sb.append( "<![CDATA[" ).append( s ).append( "]]>" );        sb.append( "</html>" );        return sb.toString();    }    // Makes XSL transformation via translet (compiled XSLT).    private String transform( String history, String translet ) {        if( history == null ) {            return null;        }        // Build the well-formed XML document.        StringBuffer sb = new StringBuffer();        sb.append( "<?xml version='1.0' encoding='UTF-8'?>" );        sb.append( HistoryConstants.HISTORY_START_TAG );        sb.append( history );        sb.append( HistoryConstants.HISTORY_END_TAG );        // Make XSLT.        StreamSource source = new StreamSource( new CharArrayReader( sb.toString().toCharArray() ) );        CharArrayWriter writer = new CharArrayWriter();        transletWrapper.transform( source, new StreamResult( writer ), translet, null );        // Ok.        return writer.toString();    }}

⌨️ 快捷键说明

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