From 7e0932bbe0f98b76a32af0496e2a65fb0481516a Mon Sep 17 00:00:00 2001 From: dubtraxis Date: Wed, 8 Oct 2003 18:24:08 +0000 Subject: [PATCH] changes to term interface --- build.xml | 42 +- src/java/log4j.properties | 69 +- src/java/org/thdl/lex/LexActionServlet.java | 112 ++- src/java/org/thdl/lex/LexComponentFilter.java | 2 +- .../org/thdl/lex/LexComponentRepository.java | 89 ++- src/java/org/thdl/lex/LexConstants.java | 40 +- src/java/org/thdl/lex/LexQuery.java | 91 ++- src/java/org/thdl/lex/LexUtilities.java | 159 ++-- src/java/org/thdl/lex/Preferences.java | 739 +++++++++++++----- .../lex/commands/GetUpdateFormCommand.java | 165 ++-- .../thdl/lex/commands/PreferencesCommand.java | 119 ++- .../org/thdl/lex/commands/UpdateCommand.java | 120 ++- .../thdl/lex/component/BaseLexComponent.java | 318 ++++++-- .../org/thdl/lex/component/ILexComponent.java | 119 ++- .../org/thdl/lex/component/LexComponent.java | 106 ++- src/java/org/thdl/lex/component/Term.java | 262 ++++++- src/js/lex.js | 12 - src/jsp/jsp/analyticalNoteForm.jsf | 6 +- src/jsp/jsp/debug.jsf | 7 + src/jsp/jsp/definitionForm.jsf | 8 +- src/jsp/jsp/displayForm.jsp | 4 +- src/jsp/jsp/displayTree.jsf | 34 +- src/jsp/jsp/encyclopediaArticleForm.jsf | 8 +- src/jsp/jsp/etymologyForm.jsf | 6 +- src/jsp/jsp/functionForm.jsf | 10 +- src/jsp/jsp/keywordForm.jsf | 6 +- src/jsp/jsp/metaForm.jsf | 14 +- src/jsp/jsp/modelSentenceForm.jsf | 6 +- src/jsp/jsp/passageForm.jsf | 6 +- src/jsp/jsp/pronunciationForm.jsf | 8 +- src/jsp/jsp/registerForm.jsf | 8 +- src/jsp/jsp/relatedTermForm.jsf | 6 +- src/jsp/jsp/spellingForm.jsf | 8 +- src/jsp/jsp/subdefinitionForm.jsf | 6 +- src/jsp/jsp/termForm.jsf | 6 +- src/jsp/jsp/transitionalDataForm.jsf | 4 +- src/jsp/jsp/translationEquivalentForm.jsf | 6 +- 37 files changed, 1997 insertions(+), 734 deletions(-) diff --git a/build.xml b/build.xml index 275aca3..c1e2bcd 100644 --- a/build.xml +++ b/build.xml @@ -1,16 +1,14 @@ - - + - - + + @@ -19,9 +17,10 @@ This is used in the classpath to bring in servlet.jar and the jdbc-driver --> + + user /pass combo should be in $TOMCAT_HOME/conf/tomcat-users.xml with manager role.--> @@ -39,27 +38,32 @@ - + - - + - + - - + + + + + + + + @@ -115,13 +119,11 @@ - + - - - - + + @@ -146,7 +148,9 @@ - + + + diff --git a/src/java/log4j.properties b/src/java/log4j.properties index 3e77d50..b4fd507 100644 --- a/src/java/log4j.properties +++ b/src/java/log4j.properties @@ -1,40 +1,37 @@ - - +### direct log messages to stdout ### +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n - +### direct messages to file hibernate.log ### +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.File=/Users/travis/webapps/lex/logs/hibernate.log +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n - +### direct messages to file lex.log ### +log4j.appender.lex-out=org.apache.log4j.FileAppender +log4j.appender.lex-out.File=/Users/travis/webapps/lex/logs/lex.log +log4j.appender.lex-out.layout=org.apache.log4j.PatternLayout +log4j.appender.lex-out.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +### set log levels - for more verbose logging change 'info' to 'debug' ## + +log4j.rootLogger=warn, stdout + +log4j.logger.net.sf.hibernate=debug, file + +log4j.logger.org.thdl.lex=debug, lex-out, file + +### enable the following line if you want to track down connection ### +### leakages when using DriverManagerConnectionProvider ### +#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace + +### log JDBC bind parameters ### +log4j.logger.net.sf.hibernate.type=info + +### log prepared statement cache activity ### +log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=info - java:comp/env/jdbc/lex-datasource - true - false - net.sf.hibernate.dialect.MySQLDialect - - - - - - diff --git a/src/java/org/thdl/lex/LexActionServlet.java b/src/java/org/thdl/lex/LexActionServlet.java index b606aee..3c5e25c 100644 --- a/src/java/org/thdl/lex/LexActionServlet.java +++ b/src/java/org/thdl/lex/LexActionServlet.java @@ -1,23 +1,25 @@ package org.thdl.lex; -import org.thdl.lex.component.*; -import org.thdl.lex.commands.*; - import java.io.IOException; +import java.util.*; +import javax.servlet.RequestDispatcher; import javax.servlet.ServletConfig; import javax.servlet.ServletException; -import javax.servlet.RequestDispatcher; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.HashMap; +import javax.servlet.http.HttpSession; +import org.apache.log4j.*; +import org.thdl.lex.commands.*; + +import org.thdl.lex.component.*; /** * Description of the Class * - *@author travis - *@created October 1, 2003 + * @author travis + * @created October 1, 2003 */ public class LexActionServlet extends HttpServlet { @@ -31,8 +33,8 @@ public class LexActionServlet extends HttpServlet /** * Sets the commands attribute of the LexActionServlet object * - *@param commands The new commands value - *@since + * @param commands The new commands value + * @since */ public void setCommands( HashMap commands ) { @@ -43,8 +45,8 @@ public class LexActionServlet extends HttpServlet /** * Sets the cmd attribute of the LexActionServlet object * - *@param cmd The new cmd value - *@since + * @param cmd The new cmd value + * @since */ public void setCmd( String cmd ) { @@ -55,8 +57,8 @@ public class LexActionServlet extends HttpServlet /** * Gets the commands attribute of the LexActionServlet object * - *@return The commands value - *@since + * @return The commands value + * @since */ public HashMap getCommands() { @@ -67,8 +69,8 @@ public class LexActionServlet extends HttpServlet /** * Gets the cmd attribute of the LexActionServlet object * - *@return The cmd value - *@since + * @return The cmd value + * @since */ public String getCmd() { @@ -81,9 +83,9 @@ public class LexActionServlet extends HttpServlet /** * Description of the Method * - *@param config Description of Parameter - *@exception ServletException Description of Exception - *@since + * @param config Description of Parameter + * @exception ServletException Description of Exception + * @since */ public void init( ServletConfig config ) throws ServletException { @@ -96,17 +98,19 @@ public class LexActionServlet extends HttpServlet /** * Description of the Method * - *@param req Description of Parameter - *@param res Description of Parameter - *@exception ServletException Description of Exception - *@exception IOException Description of Exception - *@since + * @param req Description of Parameter + * @param res Description of Parameter + * @exception ServletException Description of Exception + * @exception IOException Description of Exception + * @since */ public void service( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException { String next; try { + logRequestState( req ); + logSessionState( req.getSession( true ) ); setCmd( req.getParameter( LexConstants.COMMAND_REQ_PARAM ) ); Command command = lookupCommand( getCmd() ); LexComponent component = (LexComponent) req.getAttribute( LexConstants.COMPONENT_REQ_ATTR ); @@ -150,10 +154,10 @@ public class LexActionServlet extends HttpServlet /** * Description of the Method * - *@param cmdKey Description of Parameter - *@return Description of the Returned Value - *@exception CommandException Description of Exception - *@since + * @param cmdKey Description of Parameter + * @return Description of the Returned Value + * @exception CommandException Description of Exception + * @since */ private Command lookupCommand( String cmdKey ) throws CommandException { @@ -175,7 +179,59 @@ public class LexActionServlet extends HttpServlet /** * Description of the Method * - *@since + * @param req Description of the Parameter + */ + public void logRequestState( HttpServletRequest req ) + { + Logger logger = Logger.getLogger( "org.thdl.lex" ); + Iterator it; + Enumeration enum = req.getParameterNames(); + while ( enum.hasMoreElements() ) + { + String parm = (String) enum.nextElement(); + logger.debug( "Request Parameter " + parm + " = " + req.getParameter( parm ) ); + } + enum = req.getAttributeNames(); + while ( enum.hasMoreElements() ) + { + String att = (String) enum.nextElement(); + logger.debug( "Request Attribute " + att + " = " + req.getAttribute( att ) ); + } + } + + + /** + * Description of the Method + * + * @param ses Description of the Parameter + */ + public void logSessionState( HttpSession ses ) + { + Logger logger = Logger.getLogger( "org.thdl.lex" ); + Enumeration enum = ses.getAttributeNames(); + while ( enum.hasMoreElements() ) + { + String att = (String) enum.nextElement(); + logger.debug( "Request Attribute " + att + " = " + ses.getAttribute( att ) ); + } + LexQuery query = (LexQuery) ses.getAttribute( "query" ); + if ( null == query ) + { + return; + } + logger.debug( "Query Entry: " + query.getEntry() ); + logger.debug( "Query QueryComponent: " + query.getQueryComponent() ); + logger.debug( "Query UpdateComponent: " + query.getUpdateComponent() ); + logger.debug( "Query Results, " + query.getResults() + ", contain: " + query.getResults().values() ); + logger.debug( "Query Duration: " + query.getEntry() ); + + } + + + /** + * Description of the Method + * + * @since */ private void initCommands() { diff --git a/src/java/org/thdl/lex/LexComponentFilter.java b/src/java/org/thdl/lex/LexComponentFilter.java index 9310506..a53b2ff 100644 --- a/src/java/org/thdl/lex/LexComponentFilter.java +++ b/src/java/org/thdl/lex/LexComponentFilter.java @@ -116,7 +116,7 @@ public class LexComponentFilter implements Filter // catch (LexComponentException labe) catch ( Exception labe ) { - throw new ServletException( "LABE says: " + labe.getMessage() ); + throw new ServletException( labe ); } } diff --git a/src/java/org/thdl/lex/LexComponentRepository.java b/src/java/org/thdl/lex/LexComponentRepository.java index 159658e..94cfcc5 100644 --- a/src/java/org/thdl/lex/LexComponentRepository.java +++ b/src/java/org/thdl/lex/LexComponentRepository.java @@ -3,6 +3,7 @@ import java.sql.*; import java.util.*; import net.sf.hibernate.*; +import org.apache.log4j.*; import org.thdl.lex.component.*; @@ -26,10 +27,13 @@ public class LexComponentRepository */ private static void setStart( long startTime ) { + Logger logger = Logger.getLogger( "org.thdl.lex" ); + logger.debug( "Query start time: " + new java.util.Date( startTime ) ); start = startTime; } + /** * Gets the start attribute of the LexComponentRepository object * @@ -42,6 +46,23 @@ public class LexComponentRepository } + /** + * Gets the duration attribute of the LexComponentRepository class + * + * @return The duration value + */ + private static long getDuration() + { + long duration = now() - getStart(); + + Logger logger = Logger.getLogger( "org.thdl.lex" ); + logger.debug( "Query finish: " + new java.util.Date( now() ) ); + logger.debug( "Query duration in ms: " + duration ); + logger.info( "Query duration: " + duration / 1000 + " seconds." ); + return duration; + } + + /** * Gets the session attribute of the LexComponentRepository class * @@ -155,28 +176,80 @@ public class LexComponentRepository term = (ITerm) it.next(); lexQuery.getResults().put( term.getMetaId(), term.getTerm() ); } - lexQuery.setDuration( now() - getStart() ); + lexQuery.setDuration( getDuration() ); } /** * Description of the Method * - * @param lexQuery Description of Parameter + * @param term Description of the Parameter * @exception LexRepositoryException Description of Exception * @since */ + public static void loadTermByPk( ITerm term ) throws LexRepositoryException + { + try + { + getSession().load( term, term.getMetaId() ); + } + catch ( HibernateException he ) + { + throw new LexRepositoryException( he ); + } + } + + + /** + * Description of the Method + * + * @param lexQuery Description of the Parameter + * @exception LexRepositoryException Description of the Exception + */ public static void loadTermByPk( LexQuery lexQuery ) throws LexRepositoryException { ITerm term = assertTerm( lexQuery.getQueryComponent() ); + loadTermByPk( term ); + lexQuery.setEntry( term ); + if ( !lexQuery.getResults().containsKey( term.getMetaId() ) ) + { + lexQuery.getResults().put( term.getMetaId(), term.getTerm() ); + } + } + + + /** + * Description of the Method + * + * @param component Description of the Parameter + * @exception LexRepositoryException Description of the Exception + */ + public static void loadByPk( ILexComponent component ) throws LexRepositoryException + { + try { - getSession().load( term, term.getMetaId() ); - lexQuery.setEntry( term ); - if ( !lexQuery.getResults().containsKey( term.getMetaId() ) ) - { - lexQuery.getResults().put( term.getMetaId(), term.getTerm() ); - } + getSession().load( component, component.getMetaId() ); + } + catch ( HibernateException he ) + { + throw new LexRepositoryException( he ); + } + } + + + /** + * Description of the Method + * + * @param component Description of the Parameter + * @exception LexRepositoryException Description of the Exception + */ + public static void update( ILexComponent component ) throws LexRepositoryException + { + + try + { + getSession().update( component ); } catch ( HibernateException he ) { diff --git a/src/java/org/thdl/lex/LexConstants.java b/src/java/org/thdl/lex/LexConstants.java index ddbfe6d..c1bfa3e 100644 --- a/src/java/org/thdl/lex/LexConstants.java +++ b/src/java/org/thdl/lex/LexConstants.java @@ -1,5 +1,7 @@ package org.thdl.lex; +import org.thdl.lex.component.*; + /** * Description of the Class @@ -24,55 +26,55 @@ public class LexConstants /** * Description of the Field */ - public final static String PRONUNCIATIONLABEL_VALUE = "pronunciation"; + public final static String PRONUNCIATIONLABEL_VALUE = new Pronunciation().getLabel(); /** * Description of the Field */ - public final static String SPELLINGLABEL_VALUE = "spelling"; + public final static String SPELLINGLABEL_VALUE = new Spelling().getLabel(); /** * Description of the Field */ - public final static String ETYMOLOGYLABEL_VALUE = "etymology"; + public final static String ETYMOLOGYLABEL_VALUE = new Etymology().getLabel(); /** * Description of the Field */ - public final static String FUNCTIONLABEL_VALUE = "function"; + public final static String FUNCTIONLABEL_VALUE = new GrammaticalFunction().getLabel(); /** * Description of the Field */ - public final static String ENCYCLOPEDIA_ARTICLE_LABEL_VALUE = "encyclopediaArticle"; + public final static String ENCYCLOPEDIA_ARTICLE_LABEL_VALUE = new EncyclopediaArticle().getLabel(); /** * Description of the Field */ - public final static String DEFINITIONLABEL_VALUE = "definition"; + public final static String DEFINITIONLABEL_VALUE = new Definition().getLabel(); /** * Description of the Field */ - public final static String SUBDEFINITIONLABEL_VALUE = "subdefinition"; + public final static String SUBDEFINITIONLABEL_VALUE = new Subdefinition().getLabel(); /** * Description of the Field */ - public final static String MODELSENTENCELABEL_VALUE = "modelSentence"; + public final static String MODELSENTENCELABEL_VALUE = new ModelSentence().getLabel(); /** * Description of the Field */ - public final static String PASSAGELABEL_VALUE = "passage"; + public final static String PASSAGELABEL_VALUE = new Passage().getLabel(); /** * Description of the Field */ - public final static String TRANSLATIONLABEL_VALUE = "translationEquivalent"; + public final static String TRANSLATIONLABEL_VALUE = new TranslationEquivalent().getLabel(); /** * Description of the Field */ - public final static String RELATEDTERMLABEL_VALUE = "relatedTerm"; + public final static String RELATEDTERMLABEL_VALUE = new RelatedTerm().getLabel(); /** * Description of the Field */ - public final static String REGISTERLABEL_VALUE = "register"; + public final static String REGISTERLABEL_VALUE = new SpeechRegister().getLabel(); /** * Description of the Field */ - public final static String KEYWORDLABEL_VALUE = "keyword"; + public final static String KEYWORDLABEL_VALUE = new Keyword().getLabel(); /** * Description of the Field */ @@ -80,7 +82,16 @@ public class LexConstants /** * Description of the Field */ - public final static String ANALYTICALNOTELABEL_VALUE = "analyticalNote"; + public final static String ANALYTICALNOTELABEL_VALUE = new AnalyticalNote().getLabel(); + /** + * Description of the Field + */ + public final static String TRANSITIONALDATALABEL_VALUE = new TransitionalData().getLabel(); + /** + * Description of the Field + */ + public final static String GLOSSLABEL_VALUE = new Gloss().getLabel(); + /* REQUEST PARAM NAMES AND VALUES USED BY LexActionServlet.java */ @@ -224,5 +235,6 @@ public class LexConstants public final static String HIBERNATE_SESSION_KEY = "hib"; //public final static String URL = "jdbc:mysql://localhost/LexTorque"; + } diff --git a/src/java/org/thdl/lex/LexQuery.java b/src/java/org/thdl/lex/LexQuery.java index a786e80..b07a3b7 100644 --- a/src/java/org/thdl/lex/LexQuery.java +++ b/src/java/org/thdl/lex/LexQuery.java @@ -1,33 +1,45 @@ package org.thdl.lex; - -import org.thdl.lex.component.*; +import java.sql.*; +import java.util.*; import net.sf.hibernate.*; import org.apache.commons.beanutils.BeanUtils; -import java.util.*; -import java.sql.*; + +import org.thdl.lex.component.*; /** * Description of the Class * - *@author travis - *@created October 1, 2003 + * @author travis + * @created October 1, 2003 */ public class LexQuery { private ILexComponent queryComponent; + private ILexComponent updateComponent; private ITerm entry; private Map results; private Enumeration mode; private long duration; + /** + * Sets the updateComponent attribute of the LexQuery object + * + * @param updateComponent The new updateComponent value + */ + public void setUpdateComponent( ILexComponent updateComponent ) + { + this.updateComponent = updateComponent; + } + + /** * Sets the duration attribute of the LexQuery object * - *@param duration The new duration value - *@since + * @param duration The new duration value + * @since */ public void setDuration( long duration ) { @@ -38,8 +50,8 @@ public class LexQuery /** * Sets the queryComponent attribute of the LexQuery object * - *@param queryComponent The new queryComponent value - *@since + * @param queryComponent The new queryComponent value + * @since */ public void setQueryComponent( ILexComponent queryComponent ) { @@ -50,8 +62,8 @@ public class LexQuery /** * Sets the entry attribute of the LexQuery object * - *@param entry The new entry value - *@since + * @param entry The new entry value + * @since */ public void setEntry( ITerm entry ) { @@ -62,8 +74,8 @@ public class LexQuery /** * Sets the mode attribute of the LexQuery object * - *@param mode The new mode value - *@since + * @param mode The new mode value + * @since */ public void setMode( Enumeration mode ) { @@ -74,8 +86,8 @@ public class LexQuery /** * Sets the results attribute of the LexQuery object * - *@param results The new results value - *@since + * @param results The new results value + * @since */ public void setResults( Map results ) { @@ -83,11 +95,22 @@ public class LexQuery } + /** + * Gets the updateComponent attribute of the LexQuery object + * + * @return The updateComponent value + */ + public ILexComponent getUpdateComponent() + { + return updateComponent; + } + + /** * Gets the duration attribute of the LexQuery object * - *@return The duration value - *@since + * @return The duration value + * @since */ public long getDuration() { @@ -98,8 +121,8 @@ public class LexQuery /** * Gets the queryComponent attribute of the LexQuery object * - *@return The queryComponent value - *@since + * @return The queryComponent value + * @since */ public ILexComponent getQueryComponent() { @@ -110,8 +133,8 @@ public class LexQuery /** * Gets the entry attribute of the LexQuery object * - *@return The entry value - *@since + * @return The entry value + * @since */ public ITerm getEntry() { @@ -122,8 +145,8 @@ public class LexQuery /** * Gets the mode attribute of the LexQuery object * - *@return The mode value - *@since + * @return The mode value + * @since */ public Enumeration getMode() { @@ -134,8 +157,8 @@ public class LexQuery /** * Gets the results attribute of the LexQuery object * - *@return The results value - *@since + * @return The results value + * @since */ public Map getResults() { @@ -151,9 +174,9 @@ public class LexQuery /** * Description of the Method * - *@param parameters Description of Parameter - *@exception LexRepositoryException Description of Exception - *@since + * @param parameters Description of Parameter + * @exception LexRepositoryException Description of Exception + * @since */ public void populate( Map parameters ) throws LexRepositoryException { @@ -177,17 +200,17 @@ public class LexQuery /** * Constructor for the LexQuery object * - *@since + * @since */ public LexQuery() { } //inner classes /* - * class LexQueryMode extends Enumeration - * { - * } - */ + class LexQueryMode extends Enumeration + { + } + */ } diff --git a/src/java/org/thdl/lex/LexUtilities.java b/src/java/org/thdl/lex/LexUtilities.java index 9e6de65..3741569 100644 --- a/src/java/org/thdl/lex/LexUtilities.java +++ b/src/java/org/thdl/lex/LexUtilities.java @@ -1,26 +1,57 @@ package org.thdl.lex; - -import java.util.StringTokenizer; import java.util.HashMap; +import java.util.StringTokenizer; + + +/** + * Description of the Class + * + * @author travis + * @created October 6, 2003 + */ public class LexUtilities { -/* public static String formatTimestamp( Timestamp time ) + /** + * Gets the resultSetSize attribute of the LexUtilities class + * + * @param rs Description of the Parameter + * @return The resultSetSize value + * @exception java.sql.SQLException Description of the Exception + */ + public static int getResultSetSize( java.sql.ResultSet rs ) throws java.sql.SQLException { - // SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz"); - // Date coDate = new Date( getCreatedOn().getTime() ); - // String dateString = formatter.format( coDate ); - } */ + rs.last(); + int i = rs.getRow(); + rs.beforeFirst(); + return i; + } + + + /* + public static String formatTimestamp( Timestamp time ) + { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz"); + Date coDate = new Date( getCreatedOn().getTime() ); + String dateString = formatter.format( coDate ); + } + */ + /** + * Description of the Method + * + * @param fromString Description of the Parameter + * @return Description of the Return Value + */ public static String escape( String fromString ) { HashMap map = new HashMap(); - map.put("'", "\\'"); - /* - map.put("%", "\\%"); - map.put("_", "\\_"); - map.put("\"", "\\\""); - */ - StringBuffer targetString = new StringBuffer(""); + map.put( "'", "\\'" ); + /* + map.put("%", "\\%"); + map.put("_", "\\_"); + map.put("\"", "\\\""); + */ + StringBuffer targetString = new StringBuffer( "" ); if ( null != fromString ) { StringTokenizer tokens = new StringTokenizer( fromString, "'%_\"", true ); @@ -29,79 +60,105 @@ public class LexUtilities String temp = tokens.nextToken(); if ( map.containsKey( temp ) ) { - temp = (String)map.get( temp ); + temp = (String) map.get( temp ); } targetString.append( temp ); } } return targetString.toString(); } - public static int getResultSetSize( java.sql.ResultSet rs ) throws java.sql.SQLException + + + /** + * Description of the Method + * + * @param source Description of the Parameter + * @return Description of the Return Value + */ + public static Integer[] convertToIntegerArray( String[] source ) { - rs.last(); - int i = rs.getRow(); - rs.beforeFirst(); - return i; - } - public static int[] convertToIntArray( String[] source ) - { - if (null == source) + if ( null == source ) { return null; } - int[] target = new int[ source.length ]; - for ( int i=0; i 0 ) { results.next(); - setId( results.getInt( 1 ) ); - setUserId( results.getInt( 2 ) ); + setId( new Integer( results.getInt( 1 ) ) ); + setUserId( new Integer( results.getInt( 2 ) ) ); setPreferencesName( results.getString( 3 ) ); - setProjectSubject( results.getInt( 4 ) ); - setSource( results.getInt( 5 ) ); - setLanguage( results.getInt( 6 ) ); - setScript( results.getInt( 7 ) ); - setDialect( results.getInt( 8 ) ); + setProjectSubject( new Integer( results.getInt( 4 ) ) ); + setSource( new Integer( results.getInt( 5 ) ) ); + setLanguage( new Integer( results.getInt( 6 ) ) ); + setScript( new Integer( results.getInt( 7 ) ) ); + setDialect( new Integer( results.getInt( 8 ) ) ); setNote( results.getString( 9 ) ); Boolean bool = Boolean.valueOf( results.getString( 10 ) ); setUseDefaultProjSub( bool.booleanValue() ); @@ -180,128 +514,183 @@ public class Preferences setUseDefaultDialect( bool.booleanValue() ); bool = Boolean.valueOf( results.getString( 15 ) ); setUseDefaultNote( bool.booleanValue() ); - setProjectSubjectSet( LexUtilities.convertTokensToIntArray( results.getString( 16 ) ) ); - setSourceSet( LexUtilities.convertTokensToIntArray( results.getString( 17 ) ) ); - setLanguageSet( LexUtilities.convertTokensToIntArray( results.getString( 18 ) ) ); - setScriptSet( LexUtilities.convertTokensToIntArray( results.getString( 19 ) ) ); - setDialectSet( LexUtilities.convertTokensToIntArray(results.getString( 20 ) ) ); + setProjectSubjectSet( LexUtilities.convertTokensToIntegerArray( results.getString( 16 ) ) ); + setSourceSet( LexUtilities.convertTokensToIntegerArray( results.getString( 17 ) ) ); + setLanguageSet( LexUtilities.convertTokensToIntegerArray( results.getString( 18 ) ) ); + setScriptSet( LexUtilities.convertTokensToIntegerArray( results.getString( 19 ) ) ); + setDialectSet( LexUtilities.convertTokensToIntegerArray( results.getString( 20 ) ) ); } - else { - insertNew(); + else + { + insertNew(); } - } catch (SQLException sqle) - { throw new LexComponentException( sqle.getMessage() ); } + } + catch ( SQLException sqle ) + { + throw new LexComponentException( sqle.getMessage() ); + } } + + /** + * Description of the Method + * + * @exception LexComponentException Description of the Exception + */ public void insertNew() throws LexComponentException { - try { - String sql = "INSERT INTO Preferences ( id, userId ) VALUES ( NULL, " +getUserId() +" )"; - int i = LexRepository.getInstance().doUpdate( sql ); + try + { + String sql = "INSERT INTO Preferences ( id, userId ) VALUES ( NULL, " + getUserId() + " )"; + Integer i = new Integer( LexRepository.getInstance().doUpdate( sql ) ); setId( i ); } - catch ( LexRepositoryException lre ) { throw new LexComponentException( lre.getMessage() ); } + catch ( LexRepositoryException lre ) + { + throw new LexComponentException( lre.getMessage() ); + } } + + /** + * Description of the Method + * + * @exception LexComponentException Description of the Exception + */ public void save() throws LexComponentException { - try { - String sql = "SELECT id FROM Preferences WHERE userId = " + getUserId(); - ResultSet results = LexRepository.getInstance().doQuery( sql ); - if ( LexUtilities.getResultSetSize( results ) < 1 ) + try { - insertNew(); + String sql = "SELECT id FROM Preferences WHERE userId = " + getUserId(); + ResultSet results = LexRepository.getInstance().doQuery( sql ); + if ( LexUtilities.getResultSetSize( results ) < 1 ) + { + insertNew(); + } + StringBuffer sqlBuffer = new StringBuffer(); + sqlBuffer.append( "UPDATE Preferences SET userId = " ); + sqlBuffer.append( getUserId() ); + sqlBuffer.append( ", preferencesName = '" ); + sqlBuffer.append( getPreferencesName() ); + sqlBuffer.append( "', projectSubject = " ); + sqlBuffer.append( getProjectSubject() ); + sqlBuffer.append( ", source = " ); + sqlBuffer.append( getSource() ); + sqlBuffer.append( ", language = " ); + sqlBuffer.append( getLanguage() ); + sqlBuffer.append( ", script = " ); + sqlBuffer.append( getScript() ); + sqlBuffer.append( ", dialect = " ); + sqlBuffer.append( getDialect() ); + sqlBuffer.append( ", note = '" ); + sqlBuffer.append( getNote() ); + sqlBuffer.append( "', useDefaultProjSub = '" ); + sqlBuffer.append( getUseDefaultProjSub() ); + sqlBuffer.append( "', useDefaultSource = '" ); + sqlBuffer.append( getUseDefaultSource() ); + sqlBuffer.append( "', useDefaultLanguage = '" ); + sqlBuffer.append( getUseDefaultLanguage() ); + sqlBuffer.append( "', useDefaultScript = '" ); + sqlBuffer.append( getUseDefaultScript() ); + sqlBuffer.append( "', useDefaultDialect = '" ); + sqlBuffer.append( getUseDefaultDialect() ); + sqlBuffer.append( "', useDefaultNote = '" ); + sqlBuffer.append( getUseDefaultNote() ); + sqlBuffer.append( "', projectSubjectSet = '" ); + sqlBuffer.append( LexUtilities.convertIntegerArrayToTokens( getProjectSubjectSet() ) ); + sqlBuffer.append( "', sourceSet = '" ); + sqlBuffer.append( LexUtilities.convertIntegerArrayToTokens( getSourceSet() ) ); + sqlBuffer.append( "', languageSet = '" ); + sqlBuffer.append( LexUtilities.convertIntegerArrayToTokens( getLanguageSet() ) ); + sqlBuffer.append( "', scriptSet = '" ); + sqlBuffer.append( LexUtilities.convertIntegerArrayToTokens( getScriptSet() ) ); + sqlBuffer.append( "', dialectSet = '" ); + sqlBuffer.append( LexUtilities.convertIntegerArrayToTokens( getDialectSet() ) ); + sqlBuffer.append( "' WHERE id = " ); + sqlBuffer.append( getId() ); + + LexRepository.getInstance().doUpdate( sqlBuffer.toString() ); + } + catch ( LexRepositoryException lre ) + { + throw new LexComponentException( lre.getMessage() ); + } + catch ( SQLException sqle ) + { + throw new LexComponentException( sqle.getMessage() ); } - StringBuffer sqlBuffer = new StringBuffer(); - sqlBuffer.append( "UPDATE Preferences SET userId = "); - sqlBuffer.append( getUserId() ); - sqlBuffer.append( ", preferencesName = '"); - sqlBuffer.append( getPreferencesName() ); - sqlBuffer.append( "', projectSubject = "); - sqlBuffer.append( getProjectSubject() ); - sqlBuffer.append( ", source = "); - sqlBuffer.append( getSource() ); - sqlBuffer.append( ", language = "); - sqlBuffer.append( getLanguage() ); - sqlBuffer.append( ", script = "); - sqlBuffer.append( getScript() ); - sqlBuffer.append( ", dialect = "); - sqlBuffer.append( getDialect() ); - sqlBuffer.append( ", note = '"); - sqlBuffer.append( getNote() ); - sqlBuffer.append( "', useDefaultProjSub = '"); - sqlBuffer.append( getUseDefaultProjSub() ); - sqlBuffer.append( "', useDefaultSource = '"); - sqlBuffer.append( getUseDefaultSource() ); - sqlBuffer.append( "', useDefaultLanguage = '"); - sqlBuffer.append( getUseDefaultLanguage() ); - sqlBuffer.append( "', useDefaultScript = '"); - sqlBuffer.append( getUseDefaultScript() ); - sqlBuffer.append( "', useDefaultDialect = '"); - sqlBuffer.append( getUseDefaultDialect() ); - sqlBuffer.append( "', useDefaultNote = '"); - sqlBuffer.append( getUseDefaultNote() ); - sqlBuffer.append( "', projectSubjectSet = '"); - sqlBuffer.append( LexUtilities.convertIntArrayToTokens( getProjectSubjectSet() ) ); - sqlBuffer.append( "', sourceSet = '"); - sqlBuffer.append( LexUtilities.convertIntArrayToTokens( getSourceSet() ) ); - sqlBuffer.append( "', languageSet = '"); - sqlBuffer.append( LexUtilities.convertIntArrayToTokens( getLanguageSet() ) ); - sqlBuffer.append( "', scriptSet = '"); - sqlBuffer.append( LexUtilities.convertIntArrayToTokens( getScriptSet() ) ); - sqlBuffer.append( "', dialectSet = '"); - sqlBuffer.append( LexUtilities.convertIntArrayToTokens( getDialectSet() ) ); - sqlBuffer.append( "' WHERE id = "); - sqlBuffer.append( getId() ); - - int i = LexRepository.getInstance().doUpdate( sqlBuffer.toString() ); - } - catch ( LexRepositoryException lre ) { throw new LexComponentException( lre.getMessage() ); } - catch ( SQLException sqle ) { throw new LexComponentException( sqle.getMessage() ); } } - + + + /** + * The main program for the Preferences class + * + * @param args The command line arguments + */ + public static void main( String[] args ) + { + try + { + Preferences component = new Preferences(); + component.setUserId( new Integer( 2 ) ); + component.save(); + System.out.println( component.getId() + " " + component.getUserId() ); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + //constructors + /** + *Constructor for the Preferences object + * + * @exception LexRepositoryException Description of the Exception + * @exception LexComponentException Description of the Exception + */ public Preferences() throws LexRepositoryException, LexComponentException { - setId( 0 ); - setUserId( 1 ); - setProjectSubject( 1 ); - setSource( 1 ); - setLanguage( 1 ); - setScript( 1 ); - setDialect( 1 ); - int[] temp = { getProjectSubject() }; + setId( new Integer( 0 ) ); + setUserId( new Integer( 1 ) ); + setProjectSubject( new Integer( 1 ) ); + setSource( new Integer( 1 ) ); + setLanguage( new Integer( 1 ) ); + setScript( new Integer( 1 ) ); + setDialect( new Integer( 1 ) ); + Integer[] temp = {getProjectSubject()}; setProjectSubjectSet( temp ); - int[] temp2 = { getSource() }; + Integer[] temp2 = {getSource()}; setSourceSet( temp2 ); - int[] temp3 = { getLanguage() }; + Integer[] temp3 = {getLanguage()}; setLanguageSet( temp3 ); - int[] temp4 = { getDialect() }; + Integer[] temp4 = {getDialect()}; setDialectSet( temp4 ); - int[] temp5 = { getScript() }; + Integer[] temp5 = {getScript()}; setScriptSet( temp5 ); setNote( "Default Note" ); } - public Preferences(ThdlUser user) throws LexRepositoryException, LexComponentException + + + /** + *Constructor for the Preferences object + * + * @param user Description of the Parameter + * @exception LexRepositoryException Description of the Exception + * @exception LexComponentException Description of the Exception + */ + public Preferences( ThdlUser user ) throws LexRepositoryException, LexComponentException { this(); setUserId( user.getId() ); populate(); - /* setProjectSubject( user.getDefaultProjSub() ); - setSource( user.getDefaultSource() ); - setLanguage( user.getDefaultLanguage() ); - setScript( user.getDefaultScript() ); - setDialect( user.getDefaultDialect() ); */ - } - public static void main(String[] args) - { - try { - Preferences component = new Preferences(); - component.setUserId( 2 ); - component.save(); - System.out.println( component.getId() + " " + component.getUserId() ); - } - catch(Exception e){ e.printStackTrace(); } + /* + setProjectSubject( user.getDefaultProjSub() ); + setSource( user.getDefaultSource() ); + setLanguage( user.getDefaultLanguage() ); + setScript( user.getDefaultScript() ); + setDialect( user.getDefaultDialect() ); + */ } } diff --git a/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java b/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java index a593428..ac5e5e5 100644 --- a/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java +++ b/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java @@ -1,80 +1,133 @@ package org.thdl.lex.commands; - -import org.thdl.lex.*; -import org.thdl.lex.component.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.thdl.lex.*; +import org.thdl.lex.component.*; +import org.thdl.users.*; + + +/** + * Description of the Class + * + * @author travis + * @created October 6, 2003 + */ public class GetUpdateFormCommand extends LexCommand implements Command { -//helper methods - public String execute(HttpServletRequest req, ILexComponent component) throws CommandException +//helper methods + /** + * Description of the Method + * + * @param req Description of the Parameter + * @param component Description of the Parameter + * @return Description of the Return Value + * @exception CommandException Description of the Exception + */ + public String execute( HttpServletRequest req, ILexComponent component ) throws CommandException { - /* try - { - String msg = null; - setComponent( (LexComponent)component ); - getComponent().scrapeRequest( req ); - getComponent().query(); - if ( getComponent().getTranslationOf() > 0 ) - { - try - { - LexComponent lab = (LexComponent) getComponent().getClass().newInstance(); - lab.query( getComponent().getTranslationOf() ); - req.setAttribute( LexConstants.ORIGINALBEAN_REQ_ATTR , lab ); - } - catch (InstantiationException ie) - { - throw new LexComponentException("InstantiationException Says: " +ie.getMessage()); - } - catch (IllegalAccessException iae) - { - throw new LexComponentException("IllegalAccessException Says: " +iae.getMessage()); - } - } - Meta meta = getComponent().getMeta(); - if ( getSessionMgr().getSessionUser( req.getSession( true ) ).getId() == meta.getCreatedBy() ) - { - msg="You have reached the Update Form"; - getSessionMgr().setDisplayMode( req.getSession( true ) , "addEditForm" ); - setNext( "displayForm.jsp?formMode=update" ); - } - else - { - msg="A dictionary component can only be edited by the person who created it"; - setNext( "displayEntry.jsp" ); - } - req.setAttribute(LexConstants.MESSAGE_REQ_ATTR, msg); - */ return getNext(); -/* } - catch (LexComponentException e) + LexQuery query = getSessionMgr().getQuery( req.getSession( true ) ); + Term term = null; + try { - throw new CommandException("Lex Action Exception: " + e.getMessage()); + term = (Term) query.getEntry(); } - */ + catch ( ClassCastException cce ) + { + throw new CommandException( term.toString(), cce ); + } + String msg = null; + try + { + component.populate( req.getParameterMap() ); + ILexComponent child = term.findChild( component ); + query.setUpdateComponent( child ); + req.setAttribute( LexConstants.COMPONENT_REQ_ATTR, child ); + } + catch ( LexComponentException e ) + { + throw new CommandException( e ); + } + + //if the component is a translation of another component get the original as well to assist in editing + if ( component.getTranslationOf().intValue() > 0 ) + { + try + { + LexComponent source = (LexComponent) component.getClass().newInstance(); + Integer sourcePk = component.getTranslationOf(); + source.setMetaId( sourcePk ); + LexComponentRepository.loadByPk( source ); + req.setAttribute( LexConstants.ORIGINALBEAN_REQ_ATTR, source ); + } + catch ( InstantiationException ie ) + { + throw new CommandException( ie ); + } + catch ( IllegalAccessException iae ) + { + throw new CommandException( iae ); + } + catch ( LexRepositoryException lre ) + { + throw new CommandException( lre ); + } + } + + Integer creator = component.getMeta().getCreatedBy(); + ThdlUser user = getSessionMgr().getSessionUser( req.getSession( true ) ); + if ( user.getId().equals( creator ) || user.hasRole( "admin" ) || user.hasRole( "dev" ) ) + { + msg = "You have reached the Update Form"; + getSessionMgr().setDisplayMode( req.getSession( true ), "addEditForm" ); + setNext( "displayForm.jsp?formMode=update" ); + } + else + { + msg = "A dictionary component can only be edited by the person who created it or an administrator."; + setNext( "displayEntry.jsp" ); + } + req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg ); + return getNext(); } - public HashMap initForwards() + + + /** + * Description of the Method + * + * @return Description of the Return Value + */ + public HashMap initForwards() { HashMap map = new HashMap(); - //map.put( LexConstants.TERMLABEL_VALUE, "displayEntry.jsp?formMode=update" ); - //map.put( LexConstants.SUBDEFINITIONLABEL_VALUE, "displayEntry.jsp?formMode=update" ); - //map.put( LexConstants.TRANSLATIONLABEL_VALUE, "displayEntry.jsp?formMode=update" ); - // map.put( LexConstants.DEFINITIONLABEL_VALUE, "displayEntry.jsp" ); - // map.put( LexConstants.PASSAGELABEL_VALUE, "displayEntry.jsp" ); +//map.put( LexConstants.TERMLABEL_VALUE, "displayEntry.jsp?formMode=update" ); +//map.put( LexConstants.SUBDEFINITIONLABEL_VALUE, "displayEntry.jsp?formMode=update" ); +//map.put( LexConstants.TRANSLATIONLABEL_VALUE, "displayEntry.jsp?formMode=update" ); +// map.put( LexConstants.DEFINITIONLABEL_VALUE, "displayEntry.jsp" ); +// map.put( LexConstants.PASSAGELABEL_VALUE, "displayEntry.jsp" ); return map; } //constructors + /** + *Constructor for the GetUpdateFormCommand object + */ public GetUpdateFormCommand() { super(); - //setForwards( initForwards() ); +//setForwards( initForwards() ); } + + + /** + *Constructor for the GetUpdateFormCommand object + * + * @param next Description of the Parameter + */ public GetUpdateFormCommand( String next ) { super(); diff --git a/src/java/org/thdl/lex/commands/PreferencesCommand.java b/src/java/org/thdl/lex/commands/PreferencesCommand.java index df00ee2..b003e4e 100644 --- a/src/java/org/thdl/lex/commands/PreferencesCommand.java +++ b/src/java/org/thdl/lex/commands/PreferencesCommand.java @@ -1,69 +1,126 @@ package org.thdl.lex.commands; +import javax.servlet.http.HttpServletRequest; + import org.thdl.lex.*; import org.thdl.lex.component.*; -import javax.servlet.http.HttpServletRequest; +/** + * Description of the Class + * + * @author travis + * @created October 6, 2003 + */ public class PreferencesCommand extends LexCommand implements Command { - public String execute(HttpServletRequest req, ILexComponent component) throws CommandException + /** + * Description of the Method + * + * @param req Description of the Parameter + * @param component Description of the Parameter + * @return Description of the Return Value + * @exception CommandException Description of the Exception + */ + public String execute( HttpServletRequest req, ILexComponent component ) throws CommandException { Preferences isb = UserSessionManager.getInstance().getPreferences( req.getSession( true ) ); - if (req.getParameter( LexConstants.COMMAND_REQ_PARAM ).equals("setMetaPrefs") ) + if ( req.getParameter( LexConstants.COMMAND_REQ_PARAM ).equals( "setMetaPrefs" ) ) { - isb.setLanguageSet( LexUtilities.convertToIntArray( req.getParameterValues( "languages" ) ) ); - isb.setDialectSet( LexUtilities.convertToIntArray( req.getParameterValues( "dialects" ) ) ); - isb.setSourceSet( LexUtilities.convertToIntArray( req.getParameterValues( "sources" ) ) ); - isb.setProjectSubjectSet( LexUtilities.convertToIntArray( req.getParameterValues( "projectSubjects" ) ) ); - isb.setScriptSet( LexUtilities.convertToIntArray( req.getParameterValues( "scripts" ) ) ); + isb.setLanguageSet( LexUtilities.convertToIntegerArray( req.getParameterValues( "languages" ) ) ); + isb.setDialectSet( LexUtilities.convertToIntegerArray( req.getParameterValues( "dialects" ) ) ); + isb.setSourceSet( LexUtilities.convertToIntegerArray( req.getParameterValues( "sources" ) ) ); + isb.setProjectSubjectSet( LexUtilities.convertToIntegerArray( req.getParameterValues( "projectSubjects" ) ) ); + isb.setScriptSet( LexUtilities.convertToIntegerArray( req.getParameterValues( "scripts" ) ) ); } - else if ( req.getParameter( LexConstants.COMMAND_REQ_PARAM ).equals("setMetaDefaults") ) + else if ( req.getParameter( LexConstants.COMMAND_REQ_PARAM ).equals( "setMetaDefaults" ) ) { - isb.setLanguage( Integer.parseInt( req.getParameter( "language" ) ) ); - isb.setDialect( Integer.parseInt( req.getParameter( "dialect" ) ) ); - isb.setSource( Integer.parseInt( req.getParameter( "source" ) ) ); - isb.setProjectSubject( Integer.parseInt( req.getParameter( "projectSubject" ) ) ); - isb.setScript( Integer.parseInt( req.getParameter( "script" ) ) ); - isb.setNote( req.getParameter( "note" ) ); - if ( null != req.getParameter( "useDefaultLanguage" ) && req.getParameter( "useDefaultLanguage" ).equals( "true" ) ) + isb.setLanguage( new Integer( req.getParameter( "language" ) ) ); + isb.setDialect( new Integer( req.getParameter( "dialect" ) ) ); + isb.setSource( new Integer( req.getParameter( "source" ) ) ); + isb.setProjectSubject( new Integer( req.getParameter( "projectSubject" ) ) ); + isb.setScript( new Integer( req.getParameter( "script" ) ) ); + isb.setNote( req.getParameter( "note" ) ); + if ( null != req.getParameter( "useDefaultLanguage" ) && req.getParameter( "useDefaultLanguage" ).equals( "true" ) ) + { isb.setUseDefaultLanguage( true ); + } else - isb.setUseDefaultLanguage( false ); - if ( null != req.getParameter( "useDefaultDialect" ) && req.getParameter( "useDefaultDialect" ).equals( "true" ) ) + { + isb.setUseDefaultLanguage( false ); + } + if ( null != req.getParameter( "useDefaultDialect" ) && req.getParameter( "useDefaultDialect" ).equals( "true" ) ) + { isb.setUseDefaultDialect( true ); + } else - isb.setUseDefaultDialect( false ); - if ( null != req.getParameter( "useDefaultSource" ) && req.getParameter( "useDefaultSource" ).equals( "true" ) ) + { + isb.setUseDefaultDialect( false ); + } + if ( null != req.getParameter( "useDefaultSource" ) && req.getParameter( "useDefaultSource" ).equals( "true" ) ) + { isb.setUseDefaultSource( true ); + } else - isb.setUseDefaultSource( false ); - if ( null != req.getParameter( "useDefaultProjSub" ) && req.getParameter( "useDefaultProjSub" ).equals( "true" ) ) + { + isb.setUseDefaultSource( false ); + } + if ( null != req.getParameter( "useDefaultProjSub" ) && req.getParameter( "useDefaultProjSub" ).equals( "true" ) ) + { isb.setUseDefaultProjSub( true ); + } else - isb.setUseDefaultProjSub( false ); - if ( null != req.getParameter( "useDefaultScript" ) && req.getParameter( "useDefaultScript" ).equals( "true" ) ) + { + isb.setUseDefaultProjSub( false ); + } + if ( null != req.getParameter( "useDefaultScript" ) && req.getParameter( "useDefaultScript" ).equals( "true" ) ) + { isb.setUseDefaultScript( true ); + } else - isb.setUseDefaultScript( false ); - if ( null != req.getParameter( "useDefaultNote" ) && req.getParameter( "useDefaultNote" ).equals( "true" ) ) + { + isb.setUseDefaultScript( false ); + } + if ( null != req.getParameter( "useDefaultNote" ) && req.getParameter( "useDefaultNote" ).equals( "true" ) ) + { isb.setUseDefaultNote( true ); + } else - isb.setUseDefaultNote( false ); + { + isb.setUseDefaultNote( false ); + } } try { isb.save(); } - catch( LexComponentException lre ) + catch ( LexComponentException lre ) { throw new CommandException( "LexComponentException says: " + lre.getMessage() ); } return getNext(); } - public java.util.HashMap initForwards() { return null;} - public PreferencesCommand(String next) + + + /** + * Description of the Method + * + * @return Description of the Return Value + */ + public java.util.HashMap initForwards() { - super(next); + return null; + } + + + /** + *Constructor for the PreferencesCommand object + * + * @param next Description of the Parameter + */ + public PreferencesCommand( String next ) + { + super( next ); } } + diff --git a/src/java/org/thdl/lex/commands/UpdateCommand.java b/src/java/org/thdl/lex/commands/UpdateCommand.java index 59444cc..4e40b1b 100644 --- a/src/java/org/thdl/lex/commands/UpdateCommand.java +++ b/src/java/org/thdl/lex/commands/UpdateCommand.java @@ -1,56 +1,100 @@ package org.thdl.lex.commands; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + import org.thdl.lex.*; import org.thdl.lex.component.*; - import org.thdl.users.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; +/** + * Description of the Class + * + * @author travis + * @created October 6, 2003 + */ public class UpdateCommand extends LexCommand implements Command { -//helper methods - public String execute(HttpServletRequest req, ILexComponent component) throws CommandException +//helper methods + /** + * Description of the Method + * + * @param req Description of the Parameter + * @param component Description of the Parameter + * @return Description of the Return Value + * @exception CommandException Description of the Exception + */ + public String execute( HttpServletRequest req, ILexComponent component ) throws CommandException { - /* try - { + String msg = null; + try + { if ( CommandToken.isValid( req ) ) { - Preferences preferences=getSessionMgr().getPreferences( req.getSession(true) ); - ThdlUser user = getSessionMgr().getSessionUser( req.getSession(true) ); - String msg="Successful Update"; - - setComponent( component ); - getComponent().query( Integer.parseInt( req.getParameter("id") ) ); - getComponent().scrapeRequest( req ); - getComponent().update( user, preferences ); - - req.setAttribute(LexConstants.MESSAGE_REQ_ATTR, msg); - req.setAttribute( "jumpToLocation", getComponent().getLabel() ); - getSessionMgr().getEntry( req.getSession( true ) ).rebuild(); + ThdlUser user = getSessionMgr().getSessionUser( req.getSession( true ) ); + msg = "Successful Update"; + + /* + component.setMetaId( new Integer( req.getParameter( "metaId" ) ) ); + LexComponentRepository.loadByPk( component ); + component.populate( req.getParameterMap() ); + Date now = new Date( System.currentTimeMillis() ); + component.getMeta().setModifiedOn( now ); + component.getMeta().setModifiedBy( user.getId() ); + LexComponentRepository.update( component ); + req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg ); + req.setAttribute( "jumpToLocation", component.getLabel() ); + */ + ITerm term = getSessionMgr().getQuery( req.getSession( true ) ).getEntry(); + LexComponentRepository.update( term ); + + /* + term = new Term(); + term.setMetaId( new Integer( 1 ) ); + try + { + LexComponentRepository.loadTermByPk( term ); + } + catch ( LexRepositoryException e ) + { + throw new CommandException( "Command had trouble processing " + term, e ); + } + */ getSessionMgr().setDisplayMode( req.getSession( true ), "edit" ); } else { - String msg="Invalid Reload Attempted"; - req.setAttribute(LexConstants.MESSAGE_REQ_ATTR, msg); + msg = "Invalid Reload Attempted"; } - */ return getNext(); -/* } - catch (LexComponentException e) - { - throw new CommandException("Lex Action Exception: " + e.getMessage()); + return getNext(); } - catch (LexEntryException e) + /* + catch ( LexComponentException e ) + { + throw new CommandException( e ); + } + */ + catch ( LexRepositoryException e ) { - throw new CommandException("Lex Entry Exception: " + e.getMessage()); + throw new CommandException( "Command had trouble processing " + component, e ); } - */ } - public HashMap initForwards() + finally + { + req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg ); + } + } + + + /** + * Description of the Method + * + * @return Description of the Return Value + */ + public HashMap initForwards() { HashMap map = new HashMap(); map.put( LexConstants.TERMLABEL_VALUE, "displayEntry.jsp" ); @@ -62,11 +106,21 @@ public class UpdateCommand extends LexCommand implements Command } //constructors + /** + *Constructor for the UpdateCommand object + */ public UpdateCommand() { super(); //setForwards( initForwards() ); } + + + /** + *Constructor for the UpdateCommand object + * + * @param next Description of the Parameter + */ public UpdateCommand( String next ) { this(); diff --git a/src/java/org/thdl/lex/component/BaseLexComponent.java b/src/java/org/thdl/lex/component/BaseLexComponent.java index 32c42f5..6c3ba86 100644 --- a/src/java/org/thdl/lex/component/BaseLexComponent.java +++ b/src/java/org/thdl/lex/component/BaseLexComponent.java @@ -7,114 +7,262 @@ import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Hibernate CodeGenerator */ -abstract public class BaseLexComponent implements org.thdl.lex.component.ILexComponent,Serializable { - /** identifier field */ - private java.lang.Integer metaId; +/** + * @author Hibernate CodeGenerator + * @created October 7, 2003 + */ +public abstract class BaseLexComponent implements org.thdl.lex.component.ILexComponent, Serializable +{ - /** nullable persistent field */ - private java.lang.Integer translationOf; + /** + * identifier field + */ + private java.lang.Integer metaId; - /** persistent field */ - private java.lang.Boolean deleted; + /** + * nullable persistent field + */ + private java.lang.Integer translationOf; - /** persistent field */ - private List analyticalNotes; + /** + * persistent field + */ + private java.lang.Boolean deleted; - /** persistent field */ - private Set translations; + /** + * persistent field + */ + private List analyticalNotes; - /** persistent field */ - private org.thdl.lex.component.Meta meta; + /** + * persistent field + */ + private Set translations; - /** full constructor */ - public BaseLexComponent(java.lang.Integer translationOf, java.lang.Boolean deleted, List analyticalNotes, Set translations, org.thdl.lex.component.Meta meta) { - this.translationOf = translationOf; - this.deleted = deleted; - this.analyticalNotes = analyticalNotes; - this.translations = translations; - this.meta = meta; - } + /** + * persistent field + */ + private org.thdl.lex.component.Meta meta; - /** default constructor */ - public BaseLexComponent() { - } - /** minimal constructor */ - public BaseLexComponent(java.lang.Boolean deleted, List analyticalNotes, Set translations, org.thdl.lex.component.Meta meta) { - this.deleted = deleted; - this.analyticalNotes = analyticalNotes; - this.translations = translations; - this.meta = meta; - } + /** + * Sets the metaId attribute of the BaseLexComponent object + * + * @param metaId The new metaId value + */ + public void setMetaId( java.lang.Integer metaId ) + { + this.metaId = metaId; + } - public java.lang.Integer getMetaId() { - return this.metaId; - } - public void setMetaId(java.lang.Integer metaId) { - this.metaId = metaId; - } + /** + * Sets the translationOf attribute of the BaseLexComponent object + * + * @param translationOf The new translationOf value + */ + public void setTranslationOf( java.lang.Integer translationOf ) + { + this.translationOf = translationOf; + } - public java.lang.Integer getTranslationOf() { - return this.translationOf; - } - public void setTranslationOf(java.lang.Integer translationOf) { - this.translationOf = translationOf; - } + /** + * Sets the deleted attribute of the BaseLexComponent object + * + * @param deleted The new deleted value + */ + public void setDeleted( java.lang.Boolean deleted ) + { + this.deleted = deleted; + } - public java.lang.Boolean getDeleted() { - return this.deleted; - } - public void setDeleted(java.lang.Boolean deleted) { - this.deleted = deleted; - } + /** + * Sets the analyticalNotes attribute of the BaseLexComponent object + * + * @param analyticalNotes The new analyticalNotes value + */ + public void setAnalyticalNotes( java.util.List analyticalNotes ) + { + this.analyticalNotes = analyticalNotes; + } - public java.util.List getAnalyticalNotes() { - return this.analyticalNotes; - } - public void setAnalyticalNotes(java.util.List analyticalNotes) { - this.analyticalNotes = analyticalNotes; - } + /** + * Sets the translations attribute of the BaseLexComponent object + * + * @param translations The new translations value + */ + public void setTranslations( java.util.Set translations ) + { + this.translations = translations; + } - public java.util.Set getTranslations() { - return this.translations; - } - public void setTranslations(java.util.Set translations) { - this.translations = translations; - } + /** + * Sets the meta attribute of the BaseLexComponent object + * + * @param meta The new meta value + */ + public void setMeta( org.thdl.lex.component.Meta meta ) + { + this.meta = meta; + } - public org.thdl.lex.component.Meta getMeta() { - return this.meta; - } - public void setMeta(org.thdl.lex.component.Meta meta) { - this.meta = meta; - } + /** + * Gets the metaId attribute of the BaseLexComponent object + * + * @return The metaId value + */ + public java.lang.Integer getMetaId() + { + return this.metaId; + } - public String toString() { - return new ToStringBuilder(this) - .append("metaId", getMetaId()) - .toString(); - } - public boolean equals(Object other) { - if ( !(other instanceof BaseLexComponent) ) return false; - BaseLexComponent castOther = (BaseLexComponent) other; - return new EqualsBuilder() - .append(this.getMetaId(), castOther.getMetaId()) - .isEquals(); - } + /** + * Gets the translationOf attribute of the BaseLexComponent object + * + * @return The translationOf value + */ + public java.lang.Integer getTranslationOf() + { + return this.translationOf; + } - public int hashCode() { - return new HashCodeBuilder() - .append(getMetaId()) - .toHashCode(); - } + + /** + * Gets the deleted attribute of the BaseLexComponent object + * + * @return The deleted value + */ + public java.lang.Boolean getDeleted() + { + return this.deleted; + } + + + /** + * Gets the analyticalNotes attribute of the BaseLexComponent object + * + * @return The analyticalNotes value + */ + public java.util.List getAnalyticalNotes() + { + return this.analyticalNotes; + } + + + /** + * Gets the translations attribute of the BaseLexComponent object + * + * @return The translations value + */ + public java.util.Set getTranslations() + { + return this.translations; + } + + + /** + * Gets the meta attribute of the BaseLexComponent object + * + * @return The meta value + */ + public org.thdl.lex.component.Meta getMeta() + { + return this.meta; + } + + + /** + * Description of the Method + * + * @return Description of the Return Value + */ + public String toString() + { + return new ToStringBuilder( this ) + .append( "metaId", getMetaId() ) + .toString(); + } + + + /** + * Description of the Method + * + * @param other Description of the Parameter + * @return Description of the Return Value + */ + public boolean equals( Object other ) + { + if ( !( other instanceof BaseLexComponent ) ) + { + return false; + } + BaseLexComponent castOther = (BaseLexComponent) other; + return new EqualsBuilder() + .append( this.getMetaId(), castOther.getMetaId() ) + .isEquals(); + } + + + /** + * Description of the Method + * + * @return Description of the Return Value + */ + public int hashCode() + { + return new HashCodeBuilder() + .append( getMetaId() ) + .toHashCode(); + } + + + /** + * full constructor + * + * @param translationOf Description of the Parameter + * @param deleted Description of the Parameter + * @param analyticalNotes Description of the Parameter + * @param translations Description of the Parameter + * @param meta Description of the Parameter + */ + public BaseLexComponent( java.lang.Integer translationOf, java.lang.Boolean deleted, List analyticalNotes, Set translations, org.thdl.lex.component.Meta meta ) + { + this.translationOf = translationOf; + this.deleted = deleted; + this.analyticalNotes = analyticalNotes; + this.translations = translations; + this.meta = meta; + } + + + /** + * default constructor + */ + public BaseLexComponent() { } + + + /** + * minimal constructor + * + * @param deleted Description of the Parameter + * @param analyticalNotes Description of the Parameter + * @param translations Description of the Parameter + * @param meta Description of the Parameter + */ + public BaseLexComponent( java.lang.Boolean deleted, List analyticalNotes, Set translations, org.thdl.lex.component.Meta meta ) + { + this.deleted = deleted; + this.analyticalNotes = analyticalNotes; + this.translations = translations; + this.meta = meta; + } } + diff --git a/src/java/org/thdl/lex/component/ILexComponent.java b/src/java/org/thdl/lex/component/ILexComponent.java index 53ea18a..d0258d5 100644 --- a/src/java/org/thdl/lex/component/ILexComponent.java +++ b/src/java/org/thdl/lex/component/ILexComponent.java @@ -4,35 +4,74 @@ package org.thdl.lex.component; /** * Description of the Interface * - *@author travis - *@created October 1, 2003 + * @author travis + * @created October 1, 2003 */ public interface ILexComponent { + /** + * Sets the parent attribute of the ILexComponent object + * + * @param comp The new parent value + */ + public void setParent( ILexComponent comp ); + + + /** + * Sets the parentId attribute of the LexComponent object + * + * @param parentId The new parentId value + */ + public void setParentId( java.lang.Integer parentId ); + + + /** + * Gets the parent attribute of the LexComponent object + * + * @return The parent value + */ + public ILexComponent getParent(); + + + /** + * Gets the parentId attribute of the LexComponent object + * + * @return The parentId value + */ + public java.lang.Integer getParentId(); + + + /** + * Gets the precedence attribute of the ILexComponent object + * + * @return The precedence value + */ + public java.lang.Short getPrecedence(); + + + /** + * Sets the precedence attribute of the LexComponent object + * + * @param precedence The new precedence value + */ + public void setPrecedence( java.lang.Short precedence ); + + /** * Gets the label attribute of the ILexComponent object * - *@return The label value - *@since + * @return The label value + * @since */ public java.lang.String getLabel(); - /** - * Sets the label attribute of the ILexComponent object - * - *@param label The new label value - *@since - */ - public void setLabel( java.lang.String label ); - - /** * Gets the metaId attribute of the ILexComponent object * - *@return The metaId value - *@since + * @return The metaId value + * @since */ public java.lang.Integer getMetaId(); @@ -40,8 +79,8 @@ public interface ILexComponent /** * Sets the metaId attribute of the ILexComponent object * - *@param metaId The new metaId value - *@since + * @param metaId The new metaId value + * @since */ public void setMetaId( java.lang.Integer metaId ); @@ -49,8 +88,8 @@ public interface ILexComponent /** * Gets the translationOf attribute of the ILexComponent object * - *@return The translationOf value - *@since + * @return The translationOf value + * @since */ public java.lang.Integer getTranslationOf(); @@ -58,8 +97,8 @@ public interface ILexComponent /** * Sets the translationOf attribute of the ILexComponent object * - *@param translationOf The new translationOf value - *@since + * @param translationOf The new translationOf value + * @since */ public void setTranslationOf( java.lang.Integer translationOf ); @@ -67,8 +106,8 @@ public interface ILexComponent /** * Gets the translations attribute of the ILexComponent object * - *@return The translations value - *@since + * @return The translations value + * @since */ public java.util.Set getTranslations(); @@ -76,8 +115,8 @@ public interface ILexComponent /** * Sets the translations attribute of the ILexComponent object * - *@param translations The new translations value - *@since + * @param translations The new translations value + * @since */ public void setTranslations( java.util.Set translations ); @@ -85,8 +124,8 @@ public interface ILexComponent /** * Gets the deleted attribute of the ILexComponent object * - *@return The deleted value - *@since + * @return The deleted value + * @since */ public java.lang.Boolean getDeleted(); @@ -94,8 +133,8 @@ public interface ILexComponent /** * Sets the deleted attribute of the ILexComponent object * - *@param deleted The new deleted value - *@since + * @param deleted The new deleted value + * @since */ public void setDeleted( java.lang.Boolean deleted ); @@ -103,8 +142,8 @@ public interface ILexComponent /** * Gets the analyticalNotes attribute of the ILexComponent object * - *@return The analyticalNotes value - *@since + * @return The analyticalNotes value + * @since */ public java.util.List getAnalyticalNotes(); @@ -112,8 +151,8 @@ public interface ILexComponent /** * Sets the analyticalNotes attribute of the ILexComponent object * - *@param analyticalNotes The new analyticalNotes value - *@since + * @param analyticalNotes The new analyticalNotes value + * @since */ public void setAnalyticalNotes( java.util.List analyticalNotes ); @@ -121,8 +160,8 @@ public interface ILexComponent /** * Gets the meta attribute of the ILexComponent object * - *@return The meta value - *@since + * @return The meta value + * @since */ public org.thdl.lex.component.Meta getMeta(); @@ -130,8 +169,8 @@ public interface ILexComponent /** * Sets the meta attribute of the ILexComponent object * - *@param meta The new meta value - *@since + * @param meta The new meta value + * @since */ public void setMeta( org.thdl.lex.component.Meta meta ); @@ -139,9 +178,9 @@ public interface ILexComponent /** * Description of the Method * - *@param properties Description of Parameter - *@exception LexComponentException Description of Exception - *@since + * @param properties Description of Parameter + * @exception LexComponentException Description of Exception + * @since */ public void populate( java.util.Map properties ) throws LexComponentException; } diff --git a/src/java/org/thdl/lex/component/LexComponent.java b/src/java/org/thdl/lex/component/LexComponent.java index cde5674..456f7f1 100644 --- a/src/java/org/thdl/lex/component/LexComponent.java +++ b/src/java/org/thdl/lex/component/LexComponent.java @@ -1,53 +1,85 @@ package org.thdl.lex.component; - -import org.apache.commons.beanutils.BeanUtils; import java.io.Serializable; import java.util.*; +import org.apache.commons.beanutils.BeanUtils; + /** * Description of the Class * - *@author travis - *@created October 1, 2003 + * @author travis + * @created October 1, 2003 */ // public abstract class LexComponent extends BaseLexComponent implements Serializable public abstract class LexComponent extends BaseLexComponent implements Serializable { - private String label; + /** + * Gets the precedence attribute of the LexComponent object + * + * @return The precedence value + */ + public abstract java.lang.Short getPrecedence(); /** - * Sets the label attribute of the LexComponent object + * Sets the precedence attribute of the LexComponent object * - *@param label The new label value - *@since + * @param precedence The new precedence value */ - public void setLabel( String label ) - { - this.label = label; - } + public abstract void setPrecedence( java.lang.Short precedence ); + + + /** + * Sets the parent attribute of the LexComponent object + * + * @param comp The new parent value + */ + public abstract void setParent( ILexComponent comp ); + + + /** + * Sets the parentId attribute of the LexComponent object + * + * @param parentId The new parentId value + */ + public abstract void setParentId( java.lang.Integer parentId ); + + + /** + * Gets the parent attribute of the LexComponent object + * + * @return The parent value + */ + public abstract ILexComponent getParent(); + + + /** + * Gets the parentId attribute of the LexComponent object + * + * @return The parentId value + */ + public abstract java.lang.Integer getParentId(); /** * Gets the label attribute of the LexComponent object * - *@return The label value - *@since + * @return The label value + * @since */ public String getLabel() { - if ( null == label ) + String label = null; + StringTokenizer tokens = new StringTokenizer( this.getClass().getName(), "." ); + while ( tokens.hasMoreTokens() ) { - String labelHex = this.toString(); - int cutoff = labelHex.indexOf( "@" ); - labelHex = labelHex.substring( 0, cutoff ); - labelHex = labelHex + "." + getMetaId(); - labelHex = labelHex.replace( ".".toCharArray()[0], ":".toCharArray()[0] ); - setLabel( labelHex ); + label = tokens.nextToken(); } - return label; + String first = label.substring( 0, 1 ).toLowerCase(); + String rest = label.substring( 1, label.length() ); + return first + rest; } @@ -55,9 +87,9 @@ public abstract class LexComponent extends BaseLexComponent implements Serializa /** * Description of the Method * - *@param properties Description of Parameter - *@exception LexComponentException Description of Exception - *@since + * @param properties Description of Parameter + * @exception LexComponentException Description of Exception + * @since */ public void populate( Map properties ) throws LexComponentException { @@ -81,12 +113,12 @@ public abstract class LexComponent extends BaseLexComponent implements Serializa /** * Constructor for the LexComponent object * - *@param translationOf Description of Parameter - *@param deleted Description of Parameter - *@param analyticalNotes Description of Parameter - *@param meta Description of Parameter - *@param translations Description of Parameter - *@since + * @param translationOf Description of Parameter + * @param deleted Description of Parameter + * @param analyticalNotes Description of Parameter + * @param meta Description of Parameter + * @param translations Description of Parameter + * @since */ public LexComponent( Integer translationOf, Boolean deleted, List analyticalNotes, Set translations, Meta meta ) { @@ -97,11 +129,11 @@ public abstract class LexComponent extends BaseLexComponent implements Serializa /** * Constructor for the LexComponent object * - *@param deleted Description of Parameter - *@param analyticalNotes Description of Parameter - *@param meta Description of Parameter - *@param translations Description of Parameter - *@since + * @param deleted Description of Parameter + * @param analyticalNotes Description of Parameter + * @param meta Description of Parameter + * @param translations Description of Parameter + * @since */ public LexComponent( Boolean deleted, List analyticalNotes, Set translations, Meta meta ) { @@ -112,7 +144,7 @@ public abstract class LexComponent extends BaseLexComponent implements Serializa /** * Constructor for the LexComponent object * - *@since + * @since */ public LexComponent() { diff --git a/src/java/org/thdl/lex/component/Term.java b/src/java/org/thdl/lex/component/Term.java index 70d0472..4d6aa49 100644 --- a/src/java/org/thdl/lex/component/Term.java +++ b/src/java/org/thdl/lex/component/Term.java @@ -1,15 +1,273 @@ package org.thdl.lex.component; import java.io.Serializable; +import java.util.*; +import org.thdl.lex.LexConstants; /** * Description of the Class * - *@author travis - *@created October 3, 2003 + * @author travis + * @created October 3, 2003 */ public class Term extends BaseTerm implements Serializable { + private HashMap childMap; + //helper methods + + /** + * Gets the parentId attribute of the Term object + * + * @return The parentId value + */ + public java.lang.Integer getParentId() + { + return null; + } + + + /** + * Sets the parentId attribute of the Term object + * + * @param parentId The new parentId value + */ + public void setParentId( java.lang.Integer parentId ) + { + return; + } + + + /** + * Gets the parent attribute of the Term object + * + * @return The parent value + */ + public org.thdl.lex.component.ILexComponent getParent() + { + return null; + } + + + /** + * Sets the parent attribute of the Term object + * + * @param parent The new parent value + */ + public void setParent( org.thdl.lex.component.ILexComponent parent ) + { + return; + } + + + /** + * Sets the childMap attribute of the Term object + * + * @param childMap The new childMap value + */ + public void setChildMap( HashMap childMap ) + { + this.childMap = childMap; + } + + + /** + * Gets the childMap attribute of the Term object + * + * @return The childMap value + */ + public HashMap getChildMap() + { + return childMap; + } + + + /** + * Gets the childList attribute of the Term object + * + * @param component Description of the Parameter + * @return The childList value + */ + /* + public List getChildList( String label ) + { + List list = null; + Iterator it = getChildMap().keySet().iterator(); + while ( it.hasNext() ) + { + String key = (String) it.next(); + if ( key.equals( label ) ) + { + list = (List) getChildMap().get( key ); + } + } + return list; + } + */ + /** + * Gets the persistentChild attribute of the Term object + * + * @param component Description of the Parameter + * @return The persistentChild value + */ + public ILexComponent findChild( ILexComponent component ) + { + ILexComponent persistentChild = null; + if ( component.getParent() instanceof Term ) + { + //String label = + //List list = getChildList( label ); + List list = (List) getChildMap().get( component.getLabel() ); + for ( Iterator it = list.iterator(); it.hasNext(); ) + { + ILexComponent termChild = (ILexComponent) it.next(); + if ( termChild.getMetaId().equals( component.getMetaId() ) ) + { + persistentChild = termChild; + } + } + } + return persistentChild; + } + + + /** + * Adds a feature to the Child attribute of the Term object + * + * @param component The feature to be added to the Child attribute + * @return Description of the Return Value + */ + public ILexComponent addChild( ILexComponent component ) + { + return null; + } + + + /** + * The main program for the Term class + * + * @param args The command line arguments + */ + public static void main( String[] args ) + { + String[] labels = new String[16]; + + labels[0] = new Etymology().getLabel(); + labels[1] = new GrammaticalFunction().getLabel(); + labels[2] = new Pronunciation().getLabel(); + labels[3] = new Definition().getLabel(); + labels[4] = new EncyclopediaArticle().getLabel(); + labels[5] = new Spelling().getLabel(); + labels[6] = new AnalyticalNote().getLabel(); + labels[7] = new TransitionalData().getLabel(); + labels[8] = new Subdefinition().getLabel(); + labels[9] = new Gloss().getLabel(); + labels[10] = new Keyword().getLabel(); + labels[11] = new ModelSentence().getLabel(); + labels[12] = new Passage().getLabel(); + labels[13] = new SpeechRegister().getLabel(); + labels[14] = new RelatedTerm().getLabel(); + labels[15] = new TranslationEquivalent().getLabel(); + for ( int i = 0; i < labels.length; i++ ) + { + System.out.println( labels[i] ); + } + } + + + /** + * Description of the Method + */ + private void initChild() + { + setChildMap( new HashMap() ); + getChildMap().put( LexConstants.PRONUNCIATIONLABEL_VALUE, getPronunciations() ); + getChildMap().put( LexConstants.SPELLINGLABEL_VALUE, getSpellings() ); + getChildMap().put( LexConstants.ETYMOLOGYLABEL_VALUE, getEtymologies() ); + getChildMap().put( LexConstants.FUNCTIONLABEL_VALUE, getFunctions() ); + getChildMap().put( LexConstants.ENCYCLOPEDIA_ARTICLE_LABEL_VALUE, getEncyclopediaArticles() ); + getChildMap().put( LexConstants.DEFINITIONLABEL_VALUE, getDefinitions() ); + // getChildMap().put( LexConstants.SUBDEFINITIONLABEL_VALUE, getSubdefinitions() ); + getChildMap().put( LexConstants.MODELSENTENCELABEL_VALUE, getModelSentences() ); + getChildMap().put( LexConstants.PASSAGELABEL_VALUE, getPassages() ); + getChildMap().put( LexConstants.TRANSLATIONLABEL_VALUE, getTranslations() ); + getChildMap().put( LexConstants.RELATEDTERMLABEL_VALUE, getRelatedTerms() ); + getChildMap().put( LexConstants.REGISTERLABEL_VALUE, getRegisters() ); + getChildMap().put( LexConstants.KEYWORDLABEL_VALUE, getKeywords() ); + getChildMap().put( LexConstants.ANALYTICALNOTELABEL_VALUE, getAnalyticalNotes() ); + getChildMap().put( LexConstants.TRANSLATIONLABEL_VALUE, getTranslations() ); + } + + + + /** + *Constructor for the Term object + */ + public Term() + { + initChild(); + } + + + /** + *Constructor for the Term object + * + * @param translationOf Description of the Parameter + * @param deleted Description of the Parameter + * @param analyticalNotes Description of the Parameter + * @param translations Description of the Parameter + * @param meta Description of the Parameter + * @param term Description of the Parameter + * @param precedence Description of the Parameter + * @param pronunciations Description of the Parameter + * @param etymologies Description of the Parameter + * @param spellings Description of the Parameter + * @param functions Description of the Parameter + * @param encyclopediaArticles Description of the Parameter + * @param transitionalData Description of the Parameter + * @param definitions Description of the Parameter + * @param glosses Description of the Parameter + * @param keywords Description of the Parameter + * @param modelSentences Description of the Parameter + * @param translationEquivalents Description of the Parameter + * @param relatedTerms Description of the Parameter + * @param passages Description of the Parameter + * @param registers Description of the Parameter + */ + public Term( java.lang.Integer translationOf, java.lang.Boolean deleted, List analyticalNotes, Set translations, org.thdl.lex.component.Meta meta, java.lang.String term, java.lang.Short precedence, List pronunciations, List etymologies, List spellings, List functions, List encyclopediaArticles, List transitionalData, List definitions, List glosses, List keywords, List modelSentences, List translationEquivalents, List relatedTerms, List passages, List registers ) + { + super( translationOf, deleted, analyticalNotes, translations, meta, term, precedence, pronunciations, etymologies, spellings, functions, encyclopediaArticles, transitionalData, definitions, glosses, keywords, modelSentences, translationEquivalents, relatedTerms, passages, registers ); + initChild(); + } + + + /** + *Constructor for the Term object + * + * @param deleted Description of the Parameter + * @param analyticalNotes Description of the Parameter + * @param translations Description of the Parameter + * @param meta Description of the Parameter + * @param term Description of the Parameter + * @param pronunciations Description of the Parameter + * @param etymologies Description of the Parameter + * @param spellings Description of the Parameter + * @param functions Description of the Parameter + * @param encyclopediaArticles Description of the Parameter + * @param transitionalData Description of the Parameter + * @param definitions Description of the Parameter + * @param glosses Description of the Parameter + * @param keywords Description of the Parameter + * @param modelSentences Description of the Parameter + * @param translationEquivalents Description of the Parameter + * @param relatedTerms Description of the Parameter + * @param passages Description of the Parameter + * @param registers Description of the Parameter + */ + public Term( java.lang.Boolean deleted, List analyticalNotes, Set translations, org.thdl.lex.component.Meta meta, java.lang.String term, List pronunciations, List etymologies, List spellings, List functions, List encyclopediaArticles, List transitionalData, List definitions, List glosses, List keywords, List modelSentences, List translationEquivalents, List relatedTerms, List passages, List registers ) + { + super( deleted, analyticalNotes, translations, meta, term, pronunciations, etymologies, spellings, functions, encyclopediaArticles, transitionalData, definitions, glosses, keywords, modelSentences, translationEquivalents, relatedTerms, passages, registers ); + initChild(); + } } diff --git a/src/js/lex.js b/src/js/lex.js index f518718..ea9b9e9 100644 --- a/src/js/lex.js +++ b/src/js/lex.js @@ -66,18 +66,6 @@ if (ie) Scripts for displayTree.jsf ============================= */ -function submitForm( cmd, component, id, parentId, componentHex, parentHex ) -{ - document.forms[2].cmd.value = cmd; - document.forms[2].componentLabel.value = component; - document.forms[2].id.value = id; - document.forms[2].parentId.value = parentId; - assert( componentHex != null , "no componentHex"); - document.forms[2].componentHex.value = componentHex; - assert( parentHex != null , "no parentHex") ; - document.forms[2].parentHex.value = parentHex; - document.forms[2].submit(); -} function smile() {} diff --git a/src/jsp/jsp/analyticalNoteForm.jsf b/src/jsp/jsp/analyticalNoteForm.jsf index e4df404..8d651a9 100644 --- a/src/jsp/jsp/analyticalNoteForm.jsf +++ b/src/jsp/jsp/analyticalNoteForm.jsf @@ -8,14 +8,14 @@ - + - + @@ -30,7 +30,7 @@ - + diff --git a/src/jsp/jsp/debug.jsf b/src/jsp/jsp/debug.jsf index c95f003..e82b4c6 100644 --- a/src/jsp/jsp/debug.jsf +++ b/src/jsp/jsp/debug.jsf @@ -13,6 +13,13 @@ Validate CSS + + + + +

USER INFO

+User Roles: + diff --git a/src/jsp/jsp/definitionForm.jsf b/src/jsp/jsp/definitionForm.jsf index a6a3a98..a1fdc37 100644 --- a/src/jsp/jsp/definitionForm.jsf +++ b/src/jsp/jsp/definitionForm.jsf @@ -8,14 +8,14 @@ - + - + @@ -32,7 +32,7 @@ - +

@@ -42,7 +42,7 @@ - + diff --git a/src/jsp/jsp/displayForm.jsp b/src/jsp/jsp/displayForm.jsp index b62ef77..36c9a43 100644 --- a/src/jsp/jsp/displayForm.jsp +++ b/src/jsp/jsp/displayForm.jsp @@ -58,7 +58,7 @@ Back to: - + @@ -94,7 +94,7 @@ Back to: - + diff --git a/src/jsp/jsp/displayTree.jsf b/src/jsp/jsp/displayTree.jsf index 11ef170..74e63f5 100644 --- a/src/jsp/jsp/displayTree.jsf +++ b/src/jsp/jsp/displayTree.jsf @@ -25,11 +25,27 @@

+ + +

- + @@ -51,7 +67,7 @@ - + @@ -79,13 +95,13 @@

- - -

+
+
+
@@ -229,9 +245,9 @@

- + - + @@ -587,9 +603,9 @@ - + - + diff --git a/src/jsp/jsp/encyclopediaArticleForm.jsf b/src/jsp/jsp/encyclopediaArticleForm.jsf index 2f30347..23326c8 100644 --- a/src/jsp/jsp/encyclopediaArticleForm.jsf +++ b/src/jsp/jsp/encyclopediaArticleForm.jsf @@ -10,7 +10,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -35,7 +35,7 @@

- + diff --git a/src/jsp/jsp/etymologyForm.jsf b/src/jsp/jsp/etymologyForm.jsf index c7b1480..3018ee7 100644 --- a/src/jsp/jsp/etymologyForm.jsf +++ b/src/jsp/jsp/etymologyForm.jsf @@ -11,7 +11,7 @@ - + @@ -19,7 +19,7 @@ - + @@ -50,7 +50,7 @@ - + diff --git a/src/jsp/jsp/functionForm.jsf b/src/jsp/jsp/functionForm.jsf index 66cebdb..453842b 100644 --- a/src/jsp/jsp/functionForm.jsf +++ b/src/jsp/jsp/functionForm.jsf @@ -9,30 +9,30 @@ - + - + - +

- + - + diff --git a/src/jsp/jsp/keywordForm.jsf b/src/jsp/jsp/keywordForm.jsf index ecc2b0c..e55829f 100644 --- a/src/jsp/jsp/keywordForm.jsf +++ b/src/jsp/jsp/keywordForm.jsf @@ -7,14 +7,14 @@ - + - + @@ -29,7 +29,7 @@

- + diff --git a/src/jsp/jsp/metaForm.jsf b/src/jsp/jsp/metaForm.jsf index ba9a48b..4b01a78 100644 --- a/src/jsp/jsp/metaForm.jsf +++ b/src/jsp/jsp/metaForm.jsf @@ -17,13 +17,13 @@ - - - - - - <%-- --%> - + + + + + + <%-- --%> + diff --git a/src/jsp/jsp/modelSentenceForm.jsf b/src/jsp/jsp/modelSentenceForm.jsf index e71038d..9eda6c7 100644 --- a/src/jsp/jsp/modelSentenceForm.jsf +++ b/src/jsp/jsp/modelSentenceForm.jsf @@ -7,7 +7,7 @@ - + <%-- --%> @@ -15,7 +15,7 @@ - + <%-- --%> @@ -43,7 +43,7 @@ - + diff --git a/src/jsp/jsp/passageForm.jsf b/src/jsp/jsp/passageForm.jsf index 0f36e09..5b9a316 100644 --- a/src/jsp/jsp/passageForm.jsf +++ b/src/jsp/jsp/passageForm.jsf @@ -10,7 +10,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -51,7 +51,7 @@ - + diff --git a/src/jsp/jsp/pronunciationForm.jsf b/src/jsp/jsp/pronunciationForm.jsf index 37e7a30..a6c87e3 100644 --- a/src/jsp/jsp/pronunciationForm.jsf +++ b/src/jsp/jsp/pronunciationForm.jsf @@ -10,7 +10,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -35,7 +35,7 @@

- + diff --git a/src/jsp/jsp/registerForm.jsf b/src/jsp/jsp/registerForm.jsf index fbb3b61..fd81877 100644 --- a/src/jsp/jsp/registerForm.jsf +++ b/src/jsp/jsp/registerForm.jsf @@ -7,7 +7,7 @@ - + <%-- --%> @@ -15,7 +15,7 @@ - + <%-- --%> @@ -30,9 +30,9 @@

- + - + diff --git a/src/jsp/jsp/relatedTermForm.jsf b/src/jsp/jsp/relatedTermForm.jsf index ec71e80..f833a32 100644 --- a/src/jsp/jsp/relatedTermForm.jsf +++ b/src/jsp/jsp/relatedTermForm.jsf @@ -8,7 +8,7 @@ - + <%-- --%> @@ -17,7 +17,7 @@ - + <%-- --%> @@ -34,7 +34,7 @@

- + diff --git a/src/jsp/jsp/spellingForm.jsf b/src/jsp/jsp/spellingForm.jsf index 7526fc2..cfd3d88 100644 --- a/src/jsp/jsp/spellingForm.jsf +++ b/src/jsp/jsp/spellingForm.jsf @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -34,7 +34,7 @@

- + diff --git a/src/jsp/jsp/subdefinitionForm.jsf b/src/jsp/jsp/subdefinitionForm.jsf index 18674f6..4539379 100644 --- a/src/jsp/jsp/subdefinitionForm.jsf +++ b/src/jsp/jsp/subdefinitionForm.jsf @@ -7,14 +7,14 @@ - + - + @@ -42,7 +42,7 @@ - + diff --git a/src/jsp/jsp/termForm.jsf b/src/jsp/jsp/termForm.jsf index a7a96c2..7e57a82 100644 --- a/src/jsp/jsp/termForm.jsf +++ b/src/jsp/jsp/termForm.jsf @@ -7,7 +7,7 @@ - + @@ -15,7 +15,7 @@ - + @@ -32,7 +32,7 @@

- + diff --git a/src/jsp/jsp/transitionalDataForm.jsf b/src/jsp/jsp/transitionalDataForm.jsf index e0c8130..025a756 100644 --- a/src/jsp/jsp/transitionalDataForm.jsf +++ b/src/jsp/jsp/transitionalDataForm.jsf @@ -13,7 +13,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/src/jsp/jsp/translationEquivalentForm.jsf b/src/jsp/jsp/translationEquivalentForm.jsf index 2dcd565..c91d6eb 100644 --- a/src/jsp/jsp/translationEquivalentForm.jsf +++ b/src/jsp/jsp/translationEquivalentForm.jsf @@ -7,7 +7,7 @@ - + <%-- --%> @@ -15,7 +15,7 @@ - + <%-- --%> @@ -32,7 +32,7 @@

- +