From 60b736246b9977431d3e37ece077559a2a00ff64 Mon Sep 17 00:00:00 2001 From: aranganath Date: Mon, 14 Mar 2005 15:44:54 +0000 Subject: [PATCH] latest code --- src/java/hibernate.cfg.xml | 2 +- ...g4j.properties => log4j.properties.backup} | 34 +++--- src/java/org/thdl/lex/LexQuery.java | 2 + src/java/org/thdl/lex/component/BaseTerm.java | 9 +- .../lex/component/BaseTransitionalData.java | 9 +- src/java/org/thdl/lex/component/ITerm.java | 4 +- .../thdl/lex/component/ITransitionalData.java | 6 +- .../thdl/lex/component/LexComponent.hbm.xml | 96 +++++++---------- .../component/TransitionalDataComparator.java | 29 +++++ .../child/TransitionalDataLabel.java | 9 ++ .../org/thdl/lex/util/DictionaryImporter.java | 102 +----------------- webroot/jsp/displayTransitionalData.jsf | 2 +- webroot/jsp/displayTreeToc.jsf | 7 +- webroot/jsp/navLinks.jsf | 2 +- webroot/jsp/transitionalDataForm.jsf | 2 +- 15 files changed, 122 insertions(+), 193 deletions(-) rename src/java/{log4j.properties => log4j.properties.backup} (97%) create mode 100644 src/java/org/thdl/lex/component/TransitionalDataComparator.java diff --git a/src/java/hibernate.cfg.xml b/src/java/hibernate.cfg.xml index ac14dcb..43cb2ab 100644 --- a/src/java/hibernate.cfg.xml +++ b/src/java/hibernate.cfg.xml @@ -13,7 +13,7 @@ javauser javadude --> - false + true true net.sf.hibernate.dialect.MySQLDialect - org.thdl.lex.component.BaseLexComponent - - + - - - org.thdl.lex.component.BaseMeta @@ -35,20 +29,18 @@ - org.thdl.lex.component.BaseAnalyticalNote - + - + - org.thdl.lex.component.BaseTerm org.thdl.lex.component.LexComponentNode @@ -64,7 +56,7 @@ - + @@ -84,12 +76,11 @@ - + - - - + + @@ -104,7 +95,7 @@ - + @@ -119,7 +110,7 @@ - + @@ -130,7 +121,6 @@ - org.thdl.lex.component.BaseDefinition org.thdl.lex.component.Translatable, org.thdl.lex.component.LexComponentNode @@ -139,7 +129,7 @@ - + @@ -149,7 +139,7 @@ - + @@ -164,7 +154,7 @@ - + @@ -179,7 +169,7 @@ - + @@ -190,7 +180,6 @@ - org.thdl.lex.component.BaseSubdefinition org.thdl.lex.component.Translatable, org.thdl.lex.component.LexComponentNode @@ -199,7 +188,7 @@ - + @@ -219,7 +208,7 @@ - + @@ -234,7 +223,7 @@ - + @@ -245,7 +234,6 @@ - org.thdl.lex.component.BasePronunciation @@ -253,13 +241,12 @@ - + - org.thdl.lex.component.BaseEtymology org.thdl.lex.component.Translatable @@ -268,7 +255,7 @@ - + @@ -282,7 +269,6 @@ - org.thdl.lex.component.BaseSpelling @@ -290,13 +276,12 @@ - + - org.thdl.lex.component.BaseGrammaticalFunction @@ -304,12 +289,11 @@ - + - org.thdl.lex.component.BaseEncyclopediaArticle @@ -317,13 +301,12 @@ - + - org.thdl.lex.component.BaseGloss @@ -331,13 +314,12 @@ - + - org.thdl.lex.component.BaseKeyword @@ -345,12 +327,11 @@ - + - org.thdl.lex.component.BaseModelSentence org.thdl.lex.component.Translatable @@ -359,7 +340,7 @@ - + @@ -370,7 +351,6 @@ - org.thdl.lex.component.BaseTranslationEquivalent @@ -378,12 +358,11 @@ - + - org.thdl.lex.component.BaseRelatedTerm @@ -391,13 +370,12 @@ - + - org.thdl.lex.component.BasePassage org.thdl.lex.component.Translatable @@ -406,7 +384,7 @@ - + @@ -420,7 +398,6 @@ - org.thdl.lex.component.BaseSpeechRegister @@ -428,12 +405,11 @@ - + - org.thdl.lex.component.BaseTransitionalData @@ -441,15 +417,19 @@ - + - + - - - - + + + + + + + + \ No newline at end of file diff --git a/src/java/org/thdl/lex/component/TransitionalDataComparator.java b/src/java/org/thdl/lex/component/TransitionalDataComparator.java new file mode 100644 index 0000000..eeb6450 --- /dev/null +++ b/src/java/org/thdl/lex/component/TransitionalDataComparator.java @@ -0,0 +1,29 @@ +/* + * Created on Feb 22, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.thdl.lex.component; + +import java.util.Comparator; + +/** + * @author Anoop + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class TransitionalDataComparator implements Comparator { + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + public int compare(Object o1, Object o2) { + TransitionalData td1 = (TransitionalData) o1; + TransitionalData td2 = (TransitionalData) o2; + + return td1.getTransitionalDataLabel().getPriority().compareTo(td2.getTransitionalDataLabel().getPriority()); + } + +} diff --git a/src/java/org/thdl/lex/component/child/TransitionalDataLabel.java b/src/java/org/thdl/lex/component/child/TransitionalDataLabel.java index ddc6c2c..b31570d 100644 --- a/src/java/org/thdl/lex/component/child/TransitionalDataLabel.java +++ b/src/java/org/thdl/lex/component/child/TransitionalDataLabel.java @@ -14,6 +14,8 @@ public class TransitionalDataLabel implements Serializable { /** nullable persistent field */ private String transitionalDataLabel; + + private Integer priority; /** full constructor */ public TransitionalDataLabel(String transitionalDataLabel) { @@ -56,4 +58,11 @@ public class TransitionalDataLabel implements Serializable { return new HashCodeBuilder().append(getId()).toHashCode(); } + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } } \ No newline at end of file diff --git a/src/java/org/thdl/lex/util/DictionaryImporter.java b/src/java/org/thdl/lex/util/DictionaryImporter.java index 226c771..f952049 100644 --- a/src/java/org/thdl/lex/util/DictionaryImporter.java +++ b/src/java/org/thdl/lex/util/DictionaryImporter.java @@ -245,111 +245,11 @@ public class DictionaryImporter { term = Manipulate.replace(term, " ", " "); if (out != null) out.println(term + " - " + definition); - else if (sqlStatement != null) - addRecordManually(term, definition); else - addRecordViaHibernate(term, definition); + addRecordManually(term, definition); } - /** - * Main class to map the term and its definition to the Lex Component object - * model. Works but painfully slow! - */ - public void addRecordViaHibernate(String term, String definition) - throws Exception { - LinkedList ll; - ListIterator li; - ITerm lexTerm; - TransitionalData trans = null; - boolean found, newTerm = false; - String existingDef; - - // displaying for debugging purposes only - // System.out.println(term); - - //check to see if the term already exists - lexTerm = LexComponentRepository.loadTermByTerm(term); - - found = false; - - //if it doesn't create a new term. - if (null == lexTerm) { - // System.out.println("New term"); - lexTerm = new Term(); - lexTerm.setTerm(term); - lexTerm.setMeta(defaultMeta()); - //save the Term to the database. This step is necessary here to - // generate a unique id - LexComponentRepository.save(lexTerm); - newTerm = true; - } else { - // System.out.println("Old term"); - li = lexTerm.getTransitionalData().listIterator(); - - while (li.hasNext()) { - trans = (TransitionalData) li.next(); - if (trans.getMeta().getCreatedByProjSub().equals(proj)) { - found = true; - break; - } - } - newTerm = false; - } - - //OLD CODE - /* - * TransitionalData trans = getTransData( lexTerm.getId() ); - * - * trans.setTransitionalDataLabel( new Short( "1" ) ); - * trans.setForPublicConsumption( "true" ); trans.setTermId( - * termParent.getId() ); - * - * String newText = null; if (null != trans.getTransitionalDataText() ) - * newText = trans.getTransitionalDataText() + ". " + - * def.toString().trim(); else newText = def.toString().trim(); - * trans.setTransitionalDataText( newText ); trans.save(); - * - * out.print( termParent.getTerm() + " "); - * - * int subTarget = 30; if ( trans.getTransitionalDataText().length() < - * 40 ) subTarget = trans.getTransitionalDataText().length(); out.print( - * trans.getTransitionalDataText().substring( 0, subTarget ) ); - */ - - //NEW CODE - // check if there is already a defition for this project - if (found) { - existingDef = trans.getTransitionalDataText().trim(); - if (existingDef.equals("")) - found = false; - else if (existingDef.indexOf(definition) < 0) { - definition = existingDef + ". " + definition; - found = false; - } - } else { - // System.out.println("New definition"); - trans = new TransitionalData(); - trans.setMeta(defaultMeta()); - trans.setTransitionalDataLabel(label); - trans.setParentId(lexTerm.getMetaId()); - trans.setForPublicConsumption(publicCons); - if (newTerm) { - ll = new LinkedList(); - ll.add(trans); - lexTerm.setTransitionalData(ll); - } else - lexTerm.getTransitionalData().add(trans); - - } - - if (!found) { - trans.setTransitionalDataText(definition); - //save the Term to the database. - LexComponentRepository.save(lexTerm); - } - } - public Meta defaultMeta() { //use the file src/sql/import-updates.sql to add new metadata for use // in this method. diff --git a/webroot/jsp/displayTransitionalData.jsf b/webroot/jsp/displayTransitionalData.jsf index a5ec292..cd10f56 100644 --- a/webroot/jsp/displayTransitionalData.jsf +++ b/webroot/jsp/displayTransitionalData.jsf @@ -18,7 +18,7 @@ -
+
diff --git a/webroot/jsp/displayTreeToc.jsf b/webroot/jsp/displayTreeToc.jsf index e48feae..f8536d1 100644 --- a/webroot/jsp/displayTreeToc.jsf +++ b/webroot/jsp/displayTreeToc.jsf @@ -130,7 +130,12 @@ - + + + +">
  • --
  • +
    +
    diff --git a/webroot/jsp/navLinks.jsf b/webroot/jsp/navLinks.jsf index eb12fe5..2fff5f2 100644 --- a/webroot/jsp/navLinks.jsf +++ b/webroot/jsp/navLinks.jsf @@ -2,7 +2,7 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>