From afa2f340a1a80ef469c631cf43a220ac1054fe1c Mon Sep 17 00:00:00 2001 From: travismccauley Date: Sun, 21 Dec 2003 16:51:08 +0000 Subject: [PATCH] Big Update to fix rampant bugs with basic add/edit/remove of everything --- config/lex-context-config.xml | 8 + src/java/org/thdl/lex/LexActionServlet.java | 4 +- .../org/thdl/lex/LexComponentRepository.java | 31 +- src/java/org/thdl/lex/LexLogger.java | 23 +- .../org/thdl/lex/commands/DisplayCommand.java | 2 +- .../lex/commands/GetInsertFormCommand.java | 2 +- .../lex/commands/GetRemoveFormCommand.java | 7 + .../lex/commands/GetUpdateFormCommand.java | 11 +- .../org/thdl/lex/commands/InsertCommand.java | 32 +- .../org/thdl/lex/commands/RemoveCommand.java | 8 + .../org/thdl/lex/commands/UpdateCommand.java | 11 +- .../thdl/lex/component/BaseSubdefinition.java | 555 +++++++++++++----- .../org/thdl/lex/component/Definition.java | 38 +- .../org/thdl/lex/component/ILexComponent.java | 13 + .../org/thdl/lex/component/LexComponent.java | 50 +- .../thdl/lex/component/LexComponentNode.java | 3 + .../org/thdl/lex/component/Subdefinition.java | 16 +- src/java/org/thdl/lex/component/Term.java | 80 +-- src/jsp/jsp/analyticalNoteForm.jsf | 3 +- src/jsp/jsp/displayDefinition.jsf | 25 +- src/jsp/jsp/displayEntry.jsp | 2 + src/jsp/jsp/displayEtymology.jsf | 20 +- src/jsp/jsp/displayForm.jsp | 7 +- src/jsp/jsp/displayMeta.jsf | 8 - src/jsp/jsp/displayModelSentence.jsf | 43 +- src/jsp/jsp/displayNotes.jsf | 6 +- src/jsp/jsp/displayPassage.jsf | 10 +- src/jsp/jsp/displaySubdefinition.jsf | 41 +- src/jsp/jsp/metaForm.jsf | 18 +- src/jsp/jsp/subdefinitionForm.jsf | 2 +- 30 files changed, 771 insertions(+), 308 deletions(-) diff --git a/config/lex-context-config.xml b/config/lex-context-config.xml index 6bec1d1..cc9f25a 100644 --- a/config/lex-context-config.xml +++ b/config/lex-context-config.xml @@ -39,6 +39,10 @@ maxActive 15 + + removeAbandoned + true + @@ -87,6 +91,10 @@ maxActive 15 + + removeAbandoned + true + diff --git a/src/java/org/thdl/lex/LexActionServlet.java b/src/java/org/thdl/lex/LexActionServlet.java index 1715f78..44f232f 100644 --- a/src/java/org/thdl/lex/LexActionServlet.java +++ b/src/java/org/thdl/lex/LexActionServlet.java @@ -137,9 +137,10 @@ public class LexActionServlet extends HttpServlet rd.forward( req, res ); LexLogger.debug( "Checking Request state at end of LexActionServlet.service()" ); LexLogger.logRequestState( req ); + LexLogger.debug( "Checking Session state at end of LexActionServlet.service()" ); LexLogger.logSessionState( req ); + LexLogger.debug( "Checking Context state at end of LexActionServlet.service()" ); LexLogger.logContextState( getServletContext() ); - } @@ -199,7 +200,6 @@ public class LexActionServlet extends HttpServlet commands.put( "addAnnotation", new AddAnnotationCommand( "displayEntry.jsp", Boolean.TRUE ) ); */ commands.put( "insert", new InsertCommand( "displayEntry.jsp", Boolean.FALSE ) ); - commands.put( "addAnnotation", new InsertCommand( "displayEntry.jsp", Boolean.FALSE ) ); commands.put( "insertTerm", new InsertCommand( "displayEntry.jsp", Boolean.TRUE ) ); commands.put( "update", new UpdateCommand( "displayEntry.jsp", Boolean.FALSE ) ); diff --git a/src/java/org/thdl/lex/LexComponentRepository.java b/src/java/org/thdl/lex/LexComponentRepository.java index 5b565b8..ecf6b8d 100644 --- a/src/java/org/thdl/lex/LexComponentRepository.java +++ b/src/java/org/thdl/lex/LexComponentRepository.java @@ -267,6 +267,33 @@ public class LexComponentRepository } + /** + * Description of the Method + * + * @param pk Description of the Parameter + * @return Description of the Return Value + * @exception LexRepositoryException Description of the Exception + */ + public static ITerm findTermByPk( Integer pk ) throws LexRepositoryException + { + ITerm term = null; + + beginTransaction(); + String queryString = " FROM org.thdl.lex.component.ITerm as term WHERE term.metaId = " + pk.toString(); + try + { + Query query = getSession().createQuery( queryString ); + term = (ITerm) query.uniqueResult(); + } + catch ( HibernateException he ) + { + throw new LexRepositoryException( he ); + } + endTransaction( false ); + return term; + } + + /** * Description of the Method * @@ -274,7 +301,7 @@ public class LexComponentRepository * @exception LexRepositoryException Description of Exception * @since */ - public static void loadTermByPk( ITerm term ) throws LexRepositoryException + public static void loadTerm( ITerm term ) throws LexRepositoryException { try { @@ -299,7 +326,7 @@ public class LexComponentRepository { beginTransaction(); ITerm term = assertTerm( lexQuery.getQueryComponent() ); - loadTermByPk( term ); + loadTerm( term ); lexQuery.setEntry( term ); if ( !lexQuery.getResults().containsKey( term.getMetaId() ) ) { diff --git a/src/java/org/thdl/lex/LexLogger.java b/src/java/org/thdl/lex/LexLogger.java index b049c66..af96227 100644 --- a/src/java/org/thdl/lex/LexLogger.java +++ b/src/java/org/thdl/lex/LexLogger.java @@ -182,15 +182,20 @@ public class LexLogger */ public static void debugComponent( Object component ) { + if ( null == component ) + { + debug( "debugComponent was just handed a null component" ); + return; + } try { - LOGGER.debug( "Describing:: " + component ); + LOGGER.debug( "Describing: " + component ); String label = component instanceof ILexComponent ? ( (ILexComponent) component ).getLabel() : component.toString(); Iterator it = BeanUtils.describe( component ).entrySet().iterator(); while ( it.hasNext() ) { Map.Entry entry = (Map.Entry) it.next(); - LOGGER.debug( label + " property:: " + entry.getKey() + " = '" + entry.getValue() + "'" ); + LOGGER.debug( label + " property: " + entry.getKey() + " = '" + entry.getValue() + "'" ); } } catch ( Exception e ) @@ -198,8 +203,20 @@ public class LexLogger StringWriter writer = new StringWriter(); e.printStackTrace( new PrintWriter( writer ) ); String stackTrace = writer.getBuffer().toString(); - LOGGER.debug( "LexLogger caught an Exception:: " + stackTrace ); + LOGGER.debug( "LexLogger caught an Exception: " + stackTrace ); } } + + + /** + * Description of the Method + * + * @param term Description of the Parameter + */ + public static void debugTerm( ITerm term ) + { + debugComponent( term ); + } + } diff --git a/src/java/org/thdl/lex/commands/DisplayCommand.java b/src/java/org/thdl/lex/commands/DisplayCommand.java index c4d6604..f5bbb82 100644 --- a/src/java/org/thdl/lex/commands/DisplayCommand.java +++ b/src/java/org/thdl/lex/commands/DisplayCommand.java @@ -74,7 +74,7 @@ public class DisplayCommand extends LexCommand implements Command } else { - LexComponentRepository.loadTermByPk( term ); + LexComponentRepository.loadTerm( term ); query.setEntry( term ); if ( query.getResults().keySet().size() < 1 ) { diff --git a/src/java/org/thdl/lex/commands/GetInsertFormCommand.java b/src/java/org/thdl/lex/commands/GetInsertFormCommand.java index c253dd1..81c0571 100644 --- a/src/java/org/thdl/lex/commands/GetInsertFormCommand.java +++ b/src/java/org/thdl/lex/commands/GetInsertFormCommand.java @@ -88,7 +88,7 @@ public class GetInsertFormCommand extends LexCommand implements Command { AnalyticalNote note = new AnalyticalNote(); note.setParentId( component.getMetaId() ); - note.setAnalyticalNote( req.getParameter( "analyticalNote" ) ); + //note.setAnalyticalNote( req.getParameter( "analyticalNote" ) ); note.setPrecedence( new Integer( 0 ) ); component.setAnalyticalNotes( new LinkedList() ); component.getAnalyticalNotes().add( note ); diff --git a/src/java/org/thdl/lex/commands/GetRemoveFormCommand.java b/src/java/org/thdl/lex/commands/GetRemoveFormCommand.java index 52b18bc..9e20125 100644 --- a/src/java/org/thdl/lex/commands/GetRemoveFormCommand.java +++ b/src/java/org/thdl/lex/commands/GetRemoveFormCommand.java @@ -74,6 +74,13 @@ public class GetRemoveFormCommand extends LexCommand implements Command { component = query.getEntry(); } + else if ( component instanceof IAnalyticalNote ) + { + ILexComponent parent = term.findParent( component.getParentId() ); + List notes = parent.getAnalyticalNotes(); + int index = notes.indexOf( component ); + component = (ILexComponent) notes.get( index ); + } else if ( component instanceof Translatable && null != ( (Translatable) component ).getTranslationOf() ) { LexComponentRepository.update( term ); diff --git a/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java b/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java index 70c240f..97bdd9c 100644 --- a/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java +++ b/src/java/org/thdl/lex/commands/GetUpdateFormCommand.java @@ -68,12 +68,19 @@ public class GetUpdateFormCommand extends LexCommand implements Command try { - LexLogger.debug( "Checking component state from getUpdateFormCommand BEFORE component assignment" ); - LexLogger.debugComponent( component ); if ( isTermMode() ) { component = query.getEntry(); } + else if ( component instanceof IAnalyticalNote ) + { + ILexComponent parent = term.findParent( component.getParentId() ); + List notes = parent.getAnalyticalNotes(); + int index = notes.indexOf( component ); + component = (ILexComponent) notes.get( index ); + LexLogger.debug( "Checking component state from getUpdateFormCommand AFTER assignment to analytical Note" ); + LexLogger.debugComponent( component ); + } else if ( component instanceof Translatable && null != ( (Translatable) component ).getTranslationOf() ) { LexComponentRepository.update( term ); diff --git a/src/java/org/thdl/lex/commands/InsertCommand.java b/src/java/org/thdl/lex/commands/InsertCommand.java index 98089c1..adbe179 100644 --- a/src/java/org/thdl/lex/commands/InsertCommand.java +++ b/src/java/org/thdl/lex/commands/InsertCommand.java @@ -83,13 +83,22 @@ public class InsertCommand extends LexCommand implements Command if ( isTermMode() ) { - term = (ITerm) component; - //term.populate( req.getParameterMap() ); + query.setEntry( (ITerm) component ); + term = query.getEntry(); } else if ( component instanceof AnalyticalNote ) { + LexLogger.debug( "Debugging Component before inserting analytical note" ); + LexLogger.debugComponent( component ); ILexComponent parent = term.findParent( component.getParentId() ); - parent.getAnalyticalNotes().add( component ); + List list = parent.getAnalyticalNotes(); + if ( null == list ) + { + list = new LinkedList(); + } + list.add( component ); + parent.setAnalyticalNotes( list ); + //term.addSiblingList( parent, component, list ); } else if ( component instanceof Translatable && null != ( (Translatable) component ).getTranslationOf() ) { @@ -106,8 +115,13 @@ public class InsertCommand extends LexCommand implements Command source.setMetaId( translation.getTranslationOf() ); source.setParentId( translation.getParentId() ); source = (Translatable) term.findChild( source ); - List l = source.getTranslations(); - l.add( translation ); + List list = source.getTranslations(); + if ( null == list ) + { + list = new LinkedList(); + } + list.add( translation ); + source.setTranslations( list ); } else { @@ -124,6 +138,8 @@ public class InsertCommand extends LexCommand implements Command component.getMeta().setCreatedBy( user.getId() ); component.getMeta().setModifiedBy( user.getId() ); + LexComponentRepository.save( term ); + if ( !isTermMode() ) { term.getMeta().setModifiedOn( now ); @@ -134,6 +150,7 @@ public class InsertCommand extends LexCommand implements Command { AnalyticalNote note = new AnalyticalNote(); note.setAnalyticalNote( req.getParameter( "analyticalNote" ) ); + note.setParentId( component.getMetaId() ); note.setPrecedence( new Integer( 0 ) ); component.setAnalyticalNotes( new LinkedList() ); component.getAnalyticalNotes().add( note ); @@ -146,9 +163,10 @@ public class InsertCommand extends LexCommand implements Command LexLogger.debugComponent( component ); LexLogger.debugComponent( term ); - LexComponentRepository.save( term ); + LexComponentRepository.update( term ); msg = "Successful Update"; visit.setDisplayMode( "edit" ); + } else { @@ -167,6 +185,8 @@ public class InsertCommand extends LexCommand implements Command finally { req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg ); + LexLogger.debug( "Showing Term Map at end of InsertCommand.execute()" ); + LexLogger.debugTerm( ( (Visit) req.getSession( false ).getAttribute( "visit" ) ).getQuery().getEntry() ); } } diff --git a/src/java/org/thdl/lex/commands/RemoveCommand.java b/src/java/org/thdl/lex/commands/RemoveCommand.java index d4d8796..3789b62 100644 --- a/src/java/org/thdl/lex/commands/RemoveCommand.java +++ b/src/java/org/thdl/lex/commands/RemoveCommand.java @@ -82,6 +82,14 @@ public class RemoveCommand extends LexCommand implements Command LexComponentRepository.update( term ); query.setEntry( null ); } + else if ( component instanceof AnalyticalNote ) + { + LexLogger.debug( "Debugging Component before inserting analytical note" ); + LexLogger.debugComponent( component ); + ILexComponent parent = term.findParent( component.getParentId() ); + List notes = parent.getAnalyticalNotes(); + notes.remove( component ); + } else if ( component instanceof Translatable && null != ( (Translatable) component ).getTranslationOf() ) { Translatable translation = (Translatable) component; diff --git a/src/java/org/thdl/lex/commands/UpdateCommand.java b/src/java/org/thdl/lex/commands/UpdateCommand.java index 319a3bc..b1c0212 100644 --- a/src/java/org/thdl/lex/commands/UpdateCommand.java +++ b/src/java/org/thdl/lex/commands/UpdateCommand.java @@ -86,6 +86,15 @@ public class UpdateCommand extends LexCommand implements Command term.getMeta().populate( req.getParameterMap() ); component = term; } + else if ( component instanceof AnalyticalNote ) + { + LexLogger.debug( "Debugging Component before updating analytical note" ); + LexLogger.debugComponent( component ); + ILexComponent parent = term.findParent( component.getParentId() ); + List notes = parent.getAnalyticalNotes(); + ILexComponent ilc = (ILexComponent) notes.get( notes.indexOf( component ) ); + ilc.populate( component ); + } else if ( component instanceof Translatable && null != ( (Translatable) component ).getTranslationOf() ) { Translatable translation = (Translatable) component; @@ -125,7 +134,7 @@ public class UpdateCommand extends LexCommand implements Command LexLogger.debugComponent( component ); LexLogger.debugComponent( term ); - LexComponentRepository.save( term ); + LexComponentRepository.update( term ); msg = "Successful Update"; visit.setDisplayMode( "edit" ); } diff --git a/src/java/org/thdl/lex/component/BaseSubdefinition.java b/src/java/org/thdl/lex/component/BaseSubdefinition.java index e09cebb..778863d 100644 --- a/src/java/org/thdl/lex/component/BaseSubdefinition.java +++ b/src/java/org/thdl/lex/component/BaseSubdefinition.java @@ -4,191 +4,460 @@ import java.io.Serializable; import java.util.List; import org.apache.commons.lang.builder.ToStringBuilder; -/** @author Hibernate CodeGenerator */ -abstract public class BaseSubdefinition extends LexComponent implements org.thdl.lex.component.ISubdefinition,org.thdl.lex.component.Translatable, org.thdl.lex.component.LexComponentNode,Serializable { - /** nullable persistent field */ - private java.lang.Integer parentId; +/** + * @author Hibernate CodeGenerator + * @created December 20, 2003 + */ +public abstract class BaseSubdefinition extends LexComponent implements org.thdl.lex.component.ISubdefinition, org.thdl.lex.component.Translatable, org.thdl.lex.component.LexComponentNode, Serializable +{ - /** nullable persistent field */ - private java.lang.Integer precedence; + /** + * nullable persistent field + */ + private java.lang.Integer parentId; - /** nullable persistent field */ - private java.lang.String subdefinition; + /** + * nullable persistent field + */ + private java.lang.Integer precedence; - /** nullable persistent field */ - private java.lang.Integer translationOf; + /** + * nullable persistent field + */ + private java.lang.String subdefinition; - /** nullable persistent field */ - private org.thdl.lex.component.ILexComponent parent; + /** + * nullable persistent field + */ + private java.lang.Integer translationOf; - /** persistent field */ - private List translations; + /** + * nullable persistent field + */ + private org.thdl.lex.component.ILexComponent parent; - /** persistent field */ - private List glosses; + /** + * persistent field + */ + private List translations; - /** persistent field */ - private List keywords; + /** + * persistent field + */ + private List glosses; - /** persistent field */ - private List modelSentences; + /** + * persistent field + */ + private List keywords; - /** persistent field */ - private List translationEquivalents; + /** + * persistent field + */ + private List modelSentences; - /** persistent field */ - private List relatedTerms; + /** + * persistent field + */ + private List translationEquivalents; - /** persistent field */ - private List passages; + /** + * persistent field + */ + private List relatedTerms; - /** persistent field */ - private List registers; + /** + * persistent field + */ + private List passages; - /** full constructor */ - public BaseSubdefinition(java.lang.Boolean deleted, List analyticalNotes, org.thdl.lex.component.Meta meta, java.lang.Integer parentId, java.lang.Integer precedence, java.lang.String subdefinition, java.lang.Integer translationOf, org.thdl.lex.component.ILexComponent parent, List translations, List glosses, List keywords, List modelSentences, List translationEquivalents, List relatedTerms, List passages, List registers) { - super(deleted, analyticalNotes, meta); - this.parentId = parentId; - this.precedence = precedence; - this.subdefinition = subdefinition; - this.translationOf = translationOf; - this.parent = parent; - this.translations = translations; - this.glosses = glosses; - this.keywords = keywords; - this.modelSentences = modelSentences; - this.translationEquivalents = translationEquivalents; - this.relatedTerms = relatedTerms; - this.passages = passages; - this.registers = registers; - } + /** + * persistent field + */ + private List registers; - /** default constructor */ - public BaseSubdefinition() { - } - /** minimal constructor */ - public BaseSubdefinition(java.lang.Boolean deleted, List analyticalNotes, org.thdl.lex.component.Meta meta, List translations, List glosses, List keywords, List modelSentences, List translationEquivalents, List relatedTerms, List passages, List registers) { - super(deleted, analyticalNotes, meta); - this.translations = translations; - this.glosses = glosses; - this.keywords = keywords; - this.modelSentences = modelSentences; - this.translationEquivalents = translationEquivalents; - this.relatedTerms = relatedTerms; - this.passages = passages; - this.registers = registers; - } + /** + * full constructor + * + * @param deleted Description of the Parameter + * @param analyticalNotes Description of the Parameter + * @param meta Description of the Parameter + * @param parentId Description of the Parameter + * @param precedence Description of the Parameter + * @param subdefinition Description of the Parameter + * @param translationOf Description of the Parameter + * @param parent Description of the Parameter + * @param translations 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 BaseSubdefinition( java.lang.Boolean deleted, List analyticalNotes, org.thdl.lex.component.Meta meta, java.lang.Integer parentId, java.lang.Integer precedence, java.lang.String subdefinition, java.lang.Integer translationOf, org.thdl.lex.component.ILexComponent parent, List translations, List glosses, List keywords, List modelSentences, List translationEquivalents, List relatedTerms, List passages, List registers ) + { + super( deleted, analyticalNotes, meta ); + this.parentId = parentId; + this.precedence = precedence; + this.subdefinition = subdefinition; + this.translationOf = translationOf; + this.parent = parent; + this.translations = translations; + this.glosses = glosses; + this.keywords = keywords; + this.modelSentences = modelSentences; + this.translationEquivalents = translationEquivalents; + this.relatedTerms = relatedTerms; + this.passages = passages; + this.registers = registers; + } - public java.lang.Integer getParentId() { - return this.parentId; - } - public void setParentId(java.lang.Integer parentId) { - this.parentId = parentId; - } + /** + * default constructor + */ + public BaseSubdefinition() { } - public java.lang.Integer getPrecedence() { - return this.precedence; - } - public void setPrecedence(java.lang.Integer precedence) { - this.precedence = precedence; - } + /** + * minimal constructor + * + * @param deleted Description of the Parameter + * @param analyticalNotes Description of the Parameter + * @param meta Description of the Parameter + * @param translations 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 BaseSubdefinition( java.lang.Boolean deleted, List analyticalNotes, org.thdl.lex.component.Meta meta, List translations, List glosses, List keywords, List modelSentences, List translationEquivalents, List relatedTerms, List passages, List registers ) + { + super( deleted, analyticalNotes, meta ); + this.translations = translations; + this.glosses = glosses; + this.keywords = keywords; + this.modelSentences = modelSentences; + this.translationEquivalents = translationEquivalents; + this.relatedTerms = relatedTerms; + this.passages = passages; + this.registers = registers; + } - public java.lang.String getSubdefinition() { - return this.subdefinition; - } - public void setSubdefinition(java.lang.String subdefinition) { - this.subdefinition = subdefinition; - } + /** + * Gets the parentId attribute of the BaseSubdefinition object + * + * @return The parentId value + */ + public java.lang.Integer getParentId() + { + return this.parentId; + } - public java.lang.Integer getTranslationOf() { - return this.translationOf; - } - public void setTranslationOf(java.lang.Integer translationOf) { - this.translationOf = translationOf; - } + /** + * Sets the parentId attribute of the BaseSubdefinition object + * + * @param parentId The new parentId value + */ + public void setParentId( java.lang.Integer parentId ) + { + this.parentId = parentId; + } - public org.thdl.lex.component.ILexComponent getParent() { - return this.parent; - } - public void setParent(org.thdl.lex.component.ILexComponent parent) { - this.parent = parent; - } + /** + * Gets the precedence attribute of the BaseSubdefinition object + * + * @return The precedence value + */ + public java.lang.Integer getPrecedence() + { + return this.precedence; + } - public java.util.List getTranslations() { - return this.translations; - } - public void setTranslations(java.util.List translations) { - this.translations = translations; - } + /** + * Sets the precedence attribute of the BaseSubdefinition object + * + * @param precedence The new precedence value + */ + public void setPrecedence( java.lang.Integer precedence ) + { + if ( null == precedence ) + { + int i = getGlosses().size(); + } + if ( ( new Integer( -1 ) ).equals( precedence ) ) + { + Object o = new String(); + Integer i = (Integer) o; + } + this.precedence = precedence; + } - public java.util.List getGlosses() { - return this.glosses; - } - public void setGlosses(java.util.List glosses) { - this.glosses = glosses; - } + /** + * Gets the subdefinition attribute of the BaseSubdefinition object + * + * @return The subdefinition value + */ + public java.lang.String getSubdefinition() + { + return this.subdefinition; + } - public java.util.List getKeywords() { - return this.keywords; - } - public void setKeywords(java.util.List keywords) { - this.keywords = keywords; - } + /** + * Sets the subdefinition attribute of the BaseSubdefinition object + * + * @param subdefinition The new subdefinition value + */ + public void setSubdefinition( java.lang.String subdefinition ) + { + this.subdefinition = subdefinition; + } - public java.util.List getModelSentences() { - return this.modelSentences; - } - public void setModelSentences(java.util.List modelSentences) { - this.modelSentences = modelSentences; - } + /** + * Gets the translationOf attribute of the BaseSubdefinition object + * + * @return The translationOf value + */ + public java.lang.Integer getTranslationOf() + { + return this.translationOf; + } - public java.util.List getTranslationEquivalents() { - return this.translationEquivalents; - } - public void setTranslationEquivalents(java.util.List translationEquivalents) { - this.translationEquivalents = translationEquivalents; - } + /** + * Sets the translationOf attribute of the BaseSubdefinition object + * + * @param translationOf The new translationOf value + */ + public void setTranslationOf( java.lang.Integer translationOf ) + { + this.translationOf = translationOf; + } - public java.util.List getRelatedTerms() { - return this.relatedTerms; - } - public void setRelatedTerms(java.util.List relatedTerms) { - this.relatedTerms = relatedTerms; - } + /** + * Gets the parent attribute of the BaseSubdefinition object + * + * @return The parent value + */ + public org.thdl.lex.component.ILexComponent getParent() + { + return this.parent; + } - public java.util.List getPassages() { - return this.passages; - } - public void setPassages(java.util.List passages) { - this.passages = passages; - } + /** + * Sets the parent attribute of the BaseSubdefinition object + * + * @param parent The new parent value + */ + public void setParent( org.thdl.lex.component.ILexComponent parent ) + { + this.parent = parent; + } - public java.util.List getRegisters() { - return this.registers; - } - public void setRegisters(java.util.List registers) { - this.registers = registers; - } + /** + * Gets the translations attribute of the BaseSubdefinition object + * + * @return The translations value + */ + public java.util.List getTranslations() + { + return this.translations; + } - public String toString() { - return new ToStringBuilder(this) - .append("metaId", getMetaId()) - .toString(); - } + + /** + * Sets the translations attribute of the BaseSubdefinition object + * + * @param translations The new translations value + */ + public void setTranslations( java.util.List translations ) + { + this.translations = translations; + } + + + /** + * Gets the glosses attribute of the BaseSubdefinition object + * + * @return The glosses value + */ + public java.util.List getGlosses() + { + return this.glosses; + } + + + /** + * Sets the glosses attribute of the BaseSubdefinition object + * + * @param glosses The new glosses value + */ + public void setGlosses( java.util.List glosses ) + { + this.glosses = glosses; + } + + + /** + * Gets the keywords attribute of the BaseSubdefinition object + * + * @return The keywords value + */ + public java.util.List getKeywords() + { + return this.keywords; + } + + + /** + * Sets the keywords attribute of the BaseSubdefinition object + * + * @param keywords The new keywords value + */ + public void setKeywords( java.util.List keywords ) + { + this.keywords = keywords; + } + + + /** + * Gets the modelSentences attribute of the BaseSubdefinition object + * + * @return The modelSentences value + */ + public java.util.List getModelSentences() + { + return this.modelSentences; + } + + + /** + * Sets the modelSentences attribute of the BaseSubdefinition object + * + * @param modelSentences The new modelSentences value + */ + public void setModelSentences( java.util.List modelSentences ) + { + this.modelSentences = modelSentences; + } + + + /** + * Gets the translationEquivalents attribute of the BaseSubdefinition object + * + * @return The translationEquivalents value + */ + public java.util.List getTranslationEquivalents() + { + return this.translationEquivalents; + } + + + /** + * Sets the translationEquivalents attribute of the BaseSubdefinition object + * + * @param translationEquivalents The new translationEquivalents value + */ + public void setTranslationEquivalents( java.util.List translationEquivalents ) + { + this.translationEquivalents = translationEquivalents; + } + + + /** + * Gets the relatedTerms attribute of the BaseSubdefinition object + * + * @return The relatedTerms value + */ + public java.util.List getRelatedTerms() + { + return this.relatedTerms; + } + + + /** + * Sets the relatedTerms attribute of the BaseSubdefinition object + * + * @param relatedTerms The new relatedTerms value + */ + public void setRelatedTerms( java.util.List relatedTerms ) + { + this.relatedTerms = relatedTerms; + } + + + /** + * Gets the passages attribute of the BaseSubdefinition object + * + * @return The passages value + */ + public java.util.List getPassages() + { + return this.passages; + } + + + /** + * Sets the passages attribute of the BaseSubdefinition object + * + * @param passages The new passages value + */ + public void setPassages( java.util.List passages ) + { + this.passages = passages; + } + + + /** + * Gets the registers attribute of the BaseSubdefinition object + * + * @return The registers value + */ + public java.util.List getRegisters() + { + return this.registers; + } + + + /** + * Sets the registers attribute of the BaseSubdefinition object + * + * @param registers The new registers value + */ + public void setRegisters( java.util.List registers ) + { + this.registers = registers; + } + + + /** + * Description of the Method + * + * @return Description of the Return Value + */ + public String toString() + { + return new ToStringBuilder( this ) + .append( "metaId", getMetaId() ) + .toString(); + } } + diff --git a/src/java/org/thdl/lex/component/Definition.java b/src/java/org/thdl/lex/component/Definition.java index df7bc84..f6b23e2 100644 --- a/src/java/org/thdl/lex/component/Definition.java +++ b/src/java/org/thdl/lex/component/Definition.java @@ -3,6 +3,7 @@ package org.thdl.lex.component; import java.io.Serializable; import java.util.*; import org.thdl.lex.*; +import org.apache.commons.beanutils.MethodUtils; /** @@ -58,14 +59,18 @@ public class Definition extends BaseDefinition implements Serializable, Translat } LexComponentNode node = (LexComponentNode) component.getParent(); list = (List) node.getChildMap().get( component.getLabel() ); + LexLogger.debug( "[Definition] List derived from " + node + ": " + list ); if ( null == list ) { - Iterator it = getSubdefinitions().iterator(); - while ( it.hasNext() ) + if ( null != getSubdefinitions() ) { - ISubdefinition subdef = (ISubdefinition) it.next(); - list = subdef.findSiblings( component ); + Iterator it = getSubdefinitions().iterator(); + while ( it.hasNext() ) + { + ISubdefinition subdef = (ISubdefinition) it.next(); + list = subdef.findSiblings( component ); + } } } @@ -129,13 +134,15 @@ public class Definition extends BaseDefinition implements Serializable, Translat child = findChild( list, pk ); } - Iterator subdefinitions = getSubdefinitions().iterator(); - while ( subdefinitions.hasNext() && null == child ) + if ( null != getSubdefinitions() ) { - ISubdefinition def = (ISubdefinition) subdefinitions.next(); - child = def.findChild( pk ); + Iterator subdefinitions = getSubdefinitions().iterator(); + while ( subdefinitions.hasNext() && null == child ) + { + ISubdefinition def = (ISubdefinition) subdefinitions.next(); + child = def.findChild( pk ); + } } - return child; } @@ -150,13 +157,16 @@ public class Definition extends BaseDefinition implements Serializable, Translat public ILexComponent findChild( List list, Integer pk ) { ILexComponent child = null; - for ( Iterator it = list.iterator(); it.hasNext(); ) + if ( null != list ) { - ILexComponent lc = (LexComponent) it.next(); - if ( lc.getMetaId().equals( pk ) ) + for ( Iterator it = list.iterator(); it.hasNext(); ) { - child = lc; - break; + ILexComponent lc = (LexComponent) it.next(); + if ( lc.getMetaId().equals( pk ) ) + { + child = lc; + break; + } } } return child; diff --git a/src/java/org/thdl/lex/component/ILexComponent.java b/src/java/org/thdl/lex/component/ILexComponent.java index 81fe644..879d32d 100644 --- a/src/java/org/thdl/lex/component/ILexComponent.java +++ b/src/java/org/thdl/lex/component/ILexComponent.java @@ -1,5 +1,7 @@ package org.thdl.lex.component; +import java.util.List; + /** * Description of the Interface @@ -181,5 +183,16 @@ public interface ILexComponent * @exception LexComponentException Description of the Exception */ public void populate( ILexComponent component ) throws LexComponentException; + + + /** + * Adds a feature to the SiblingList attribute of the LexComponentNode object + * + * @param component The feature to be added to the SiblingList attribute + * @param list The feature to be added to the SiblingList attribute + * @param parent The feature to be added to the SiblingList attribute + * @exception LexComponentException Description of the Exception + */ + public void addSiblingList( ILexComponent parent, ILexComponent component, List list ) throws LexComponentException; } diff --git a/src/java/org/thdl/lex/component/LexComponent.java b/src/java/org/thdl/lex/component/LexComponent.java index a5d646f..e6bf0c6 100644 --- a/src/java/org/thdl/lex/component/LexComponent.java +++ b/src/java/org/thdl/lex/component/LexComponent.java @@ -3,6 +3,7 @@ import java.io.Serializable; import java.util.*; import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.beanutils.MethodUtils; /** @@ -206,6 +207,44 @@ public abstract class LexComponent extends BaseLexComponent implements Serializa } + /** + * Uses component.label to find the correct sibling list in 'parent' and set it to 'list' + * + * @param component The feature to be added to the SiblingList attribute + * @param list The feature to be added to the SiblingList attribute + * @param parent The feature to be added to the SiblingList attribute + * @exception LexComponentException Description of the Exception + */ + public void addSiblingList( ILexComponent parent, ILexComponent component, List list ) throws LexComponentException + { + String label = component.getLabel(); + + if ( label.equals( "etymology" ) ) + { + label = "etymologies"; + } + else if ( label.equals( "transitionalData" ) ) + { + label = "transitionalData"; + } + else + { + label = label + "s"; + } + char[] chars = label.toCharArray(); + chars[0] = Character.toUpperCase( chars[0] ); + label = "set" + new String( chars ); + try + { + Object iAmVoid = MethodUtils.invokeMethod( parent, label, list ); + } + catch ( Exception e ) + { + throw new LexComponentException( e ); + } + } + + /** * Description of the Method * @@ -214,12 +253,17 @@ public abstract class LexComponent extends BaseLexComponent implements Serializa */ public boolean equals( Object o ) { - boolean b = false; + boolean rVal = false; if ( o instanceof ILexComponent ) { - b = this.metaId.equals( ( (ILexComponent) o ).getMetaId() ); + Integer a = ( (ILexComponent) o ).getMetaId(); + Integer b = this.getMetaId(); + if ( null != a && null != b ) + { + rVal = a.equals( b ); + } } - return b; + return rVal; } //constructors diff --git a/src/java/org/thdl/lex/component/LexComponentNode.java b/src/java/org/thdl/lex/component/LexComponentNode.java index 5606eb5..1abc615 100644 --- a/src/java/org/thdl/lex/component/LexComponentNode.java +++ b/src/java/org/thdl/lex/component/LexComponentNode.java @@ -1,5 +1,7 @@ package org.thdl.lex.component; +import java.util.List; + /** * Description of the Interface @@ -29,5 +31,6 @@ public interface LexComponentNode extends ILexComponent * @exception LexComponentException Description of the Exception */ public java.util.List findSiblings( ILexComponent component ) throws LexComponentException; + } diff --git a/src/java/org/thdl/lex/component/Subdefinition.java b/src/java/org/thdl/lex/component/Subdefinition.java index d817f7d..57765cf 100644 --- a/src/java/org/thdl/lex/component/Subdefinition.java +++ b/src/java/org/thdl/lex/component/Subdefinition.java @@ -3,6 +3,7 @@ package org.thdl.lex.component; import java.io.Serializable; import java.util.*; import org.thdl.lex.*; +import org.apache.commons.beanutils.MethodUtils; @@ -87,6 +88,8 @@ public class Subdefinition extends BaseSubdefinition implements Serializable, Tr } + + /** * Gets the persistentChild attribute of the Term object * @@ -133,13 +136,16 @@ public class Subdefinition extends BaseSubdefinition implements Serializable, Tr public ILexComponent findChild( List list, Integer pk ) { ILexComponent child = null; - for ( Iterator it = list.iterator(); it.hasNext(); ) + if ( list != null ) { - ILexComponent lc = (LexComponent) it.next(); - if ( lc.getMetaId().equals( pk ) ) + for ( Iterator it = list.iterator(); it.hasNext(); ) { - child = lc; - break; + ILexComponent lc = (LexComponent) it.next(); + if ( lc.getMetaId().equals( pk ) ) + { + child = lc; + break; + } } } return child; diff --git a/src/java/org/thdl/lex/component/Term.java b/src/java/org/thdl/lex/component/Term.java index 9641c90..bd5a45b 100644 --- a/src/java/org/thdl/lex/component/Term.java +++ b/src/java/org/thdl/lex/component/Term.java @@ -5,6 +5,7 @@ import java.util.*; import org.thdl.lex.*; + /** * Description of the Class * @@ -102,18 +103,21 @@ public class Term extends BaseTerm implements Serializable, LexComponentNode } LexComponentNode node = (LexComponentNode) component.getParent(); list = (List) node.getChildMap().get( component.getLabel() ); - LexLogger.debug( "List derived from " + node + ": " + list ); + LexLogger.debug( "[Term] List derived from " + node + ": " + list ); if ( null == list ) { LexLogger.debug( "findSiblings returned a null list" ); LexLogger.debugComponent( component ); - Iterator it = getDefinitions().iterator(); - while ( it.hasNext() ) + if ( null != getDefinitions() ) { - IDefinition def = (IDefinition) it.next(); - list = def.findSiblings( component ); + Iterator it = getDefinitions().iterator(); + while ( it.hasNext() ) + { + IDefinition def = (IDefinition) it.next(); + list = def.findSiblings( component ); + } } } @@ -160,20 +164,6 @@ public class Term extends BaseTerm implements Serializable, LexComponentNode } - /** - * Description of the Method - * - * @param child Description of the Parameter - * @exception LexComponentException Description of the Exception - */ - public void removeChild( ILexComponent child ) throws LexComponentException - { - List list = findSiblings( child ); - child = findChild( list, child.getMetaId() ); - list.remove( child ); - } - - /** * Description of the Method * @@ -184,21 +174,21 @@ public class Term extends BaseTerm implements Serializable, LexComponentNode public ILexComponent findChild( Integer pk ) throws LexComponentException { ILexComponent child = null; - Iterator childMapValues = getChildMap().values().iterator(); while ( childMapValues.hasNext() && null == child ) { List list = (List) childMapValues.next(); child = findChild( list, pk ); } - - Iterator definitions = getDefinitions().iterator(); - while ( definitions.hasNext() && null == child ) + if ( null != getDefinitions() ) { - IDefinition def = (IDefinition) definitions.next(); - child = def.findChild( pk ); + Iterator definitions = getDefinitions().iterator(); + while ( definitions.hasNext() && null == child ) + { + IDefinition def = (IDefinition) definitions.next(); + child = def.findChild( pk ); + } } - return child; } @@ -210,16 +200,20 @@ public class Term extends BaseTerm implements Serializable, LexComponentNode * @param pk Description of the Parameter * @return Description of the Return Value */ + public ILexComponent findChild( List list, Integer pk ) { ILexComponent child = null; - for ( Iterator it = list.iterator(); it.hasNext(); ) + if ( list != null ) { - ILexComponent lc = (LexComponent) it.next(); - if ( lc.getMetaId().equals( pk ) ) + for ( Iterator it = list.iterator(); it.hasNext(); ) { - child = lc; - break; + ILexComponent lc = (LexComponent) it.next(); + if ( lc.getMetaId().equals( pk ) ) + { + child = lc; + break; + } } } return child; @@ -235,9 +229,29 @@ public class Term extends BaseTerm implements Serializable, LexComponentNode public void addChild( ILexComponent component ) throws LexComponentException { List list = findSiblings( component ); + if ( list == null ) + { + list = new LinkedList(); + LexComponentNode parent = (LexComponentNode) component.getParent(); + parent.addSiblingList( parent, component, list ); + parent.getChildMap().put( component.getLabel(), list ); + } list.add( component ); - int precedence = list.indexOf( component ); - component.setPrecedence( new Integer( precedence ) ); + } + + + + /** + * Description of the Method + * + * @param child Description of the Parameter + * @exception LexComponentException Description of the Exception + */ + public void removeChild( ILexComponent child ) throws LexComponentException + { + List list = findSiblings( child ); + int index = list.indexOf( child ); + list.remove( index ); } diff --git a/src/jsp/jsp/analyticalNoteForm.jsf b/src/jsp/jsp/analyticalNoteForm.jsf index 5e392b1..0910918 100644 --- a/src/jsp/jsp/analyticalNoteForm.jsf +++ b/src/jsp/jsp/analyticalNoteForm.jsf @@ -5,9 +5,10 @@ - + + diff --git a/src/jsp/jsp/displayDefinition.jsf b/src/jsp/jsp/displayDefinition.jsf index 17abb4b..55f547c 100644 --- a/src/jsp/jsp/displayDefinition.jsf +++ b/src/jsp/jsp/displayDefinition.jsf @@ -26,29 +26,38 @@ +

- + + +

Translations

+
    - +
  • +

    + - + + + + - view/edit translation - - + - +

    +
  • +
+
-

diff --git a/src/jsp/jsp/displayEntry.jsp b/src/jsp/jsp/displayEntry.jsp index a9b8a21..ec7b9f5 100644 --- a/src/jsp/jsp/displayEntry.jsp +++ b/src/jsp/jsp/displayEntry.jsp @@ -37,6 +37,7 @@ +

Search Results

    @@ -52,6 +53,7 @@
+
diff --git a/src/jsp/jsp/displayEtymology.jsf b/src/jsp/jsp/displayEtymology.jsf index df46a10..281b329 100644 --- a/src/jsp/jsp/displayEtymology.jsf +++ b/src/jsp/jsp/displayEtymology.jsf @@ -34,6 +34,7 @@ +

@@ -44,20 +45,19 @@
  • - - <%-- +

    + - - - view/edit translation--%> + + + + + + -
    -
    -
    -
    @@ -65,6 +65,7 @@ +

  • @@ -74,5 +75,4 @@ -

    diff --git a/src/jsp/jsp/displayForm.jsp b/src/jsp/jsp/displayForm.jsp index 0eb96c4..dde0264 100644 --- a/src/jsp/jsp/displayForm.jsp +++ b/src/jsp/jsp/displayForm.jsp @@ -61,11 +61,12 @@ Back to: -

    +

    Note

    +

    -

    +

    @@ -126,7 +127,7 @@ Back to: <%--Insert Form--%> - + diff --git a/src/jsp/jsp/displayMeta.jsf b/src/jsp/jsp/displayMeta.jsf index fca7841..a1f4799 100644 --- a/src/jsp/jsp/displayMeta.jsf +++ b/src/jsp/jsp/displayMeta.jsf @@ -40,14 +40,6 @@ Dialect:
    Translation: -<%-- - -Yes (of ) - - -No - - --%>
    Note:
    diff --git a/src/jsp/jsp/displayModelSentence.jsf b/src/jsp/jsp/displayModelSentence.jsf index 07d39f2..f2cb5c2 100644 --- a/src/jsp/jsp/displayModelSentence.jsf +++ b/src/jsp/jsp/displayModelSentence.jsf @@ -18,49 +18,46 @@ - - - - +

    - -

    Translations

      -
    • - <%-- - - - - - view/edit translation --%> - - - - +

      + + + + + + + + + - - - +

    • -
      +
    + + + + + + + -

    - diff --git a/src/jsp/jsp/displayNotes.jsf b/src/jsp/jsp/displayNotes.jsf index 24106e0..771149c 100644 --- a/src/jsp/jsp/displayNotes.jsf +++ b/src/jsp/jsp/displayNotes.jsf @@ -11,10 +11,11 @@
    1. +

      - - + + @@ -31,6 +32,7 @@ +

    diff --git a/src/jsp/jsp/displayPassage.jsf b/src/jsp/jsp/displayPassage.jsf index bd085f2..ffd9658 100644 --- a/src/jsp/jsp/displayPassage.jsf +++ b/src/jsp/jsp/displayPassage.jsf @@ -56,9 +56,9 @@ +

    -

    Translations

    @@ -72,15 +72,9 @@
    - <%-- - - - --%> - <%-- --%> -
    @@ -95,7 +89,6 @@
    - <%-- --%> @@ -113,5 +106,4 @@ -

    diff --git a/src/jsp/jsp/displaySubdefinition.jsf b/src/jsp/jsp/displaySubdefinition.jsf index e046dc8..68113e1 100644 --- a/src/jsp/jsp/displaySubdefinition.jsf +++ b/src/jsp/jsp/displaySubdefinition.jsf @@ -25,33 +25,38 @@ - - - - - + - - - - +

    + + + + +

    Translations

    +
      + +
    • +

      + - + + + + - view/edit translation - - - - - + + - +

      +
    • +
      +
    +
    - diff --git a/src/jsp/jsp/metaForm.jsf b/src/jsp/jsp/metaForm.jsf index 4df5d4c..8e7f007 100644 --- a/src/jsp/jsp/metaForm.jsf +++ b/src/jsp/jsp/metaForm.jsf @@ -12,7 +12,7 @@ - <%-- --%> +
    @@ -22,7 +22,7 @@ - <%-- --%> + @@ -32,17 +32,18 @@ - <%-- --%>
    - - - -<%-- - + +<%-- + --%> + + + +

    @@ -71,7 +72,6 @@ Language: - <%-- --%> diff --git a/src/jsp/jsp/subdefinitionForm.jsf b/src/jsp/jsp/subdefinitionForm.jsf index 4d02a62..dc31bef 100644 --- a/src/jsp/jsp/subdefinitionForm.jsf +++ b/src/jsp/jsp/subdefinitionForm.jsf @@ -48,7 +48,7 @@ Subdefinition:
    - +
    <%-- Precedence: