You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(18) |
Aug
(33) |
Sep
(30) |
Oct
(27) |
Nov
(59) |
Dec
(30) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(67) |
Feb
(44) |
Mar
(70) |
Apr
(73) |
May
(119) |
Jun
(31) |
Jul
(92) |
Aug
(86) |
Sep
(76) |
Oct
(152) |
Nov
(156) |
Dec
(85) |
2008 |
Jan
(111) |
Feb
(121) |
Mar
(107) |
Apr
(102) |
May
(45) |
Jun
(65) |
Jul
(62) |
Aug
(133) |
Sep
(56) |
Oct
(56) |
Nov
(17) |
Dec
(15) |
2009 |
Jan
(10) |
Feb
(5) |
Mar
(10) |
Apr
(14) |
May
(49) |
Jun
(94) |
Jul
(67) |
Aug
(23) |
Sep
(9) |
Oct
(92) |
Nov
(26) |
Dec
(51) |
2010 |
Jan
(105) |
Feb
(83) |
Mar
(52) |
Apr
(59) |
May
(68) |
Jun
(71) |
Jul
(127) |
Aug
(49) |
Sep
(91) |
Oct
(27) |
Nov
(33) |
Dec
(26) |
2011 |
Jan
(26) |
Feb
(45) |
Mar
(26) |
Apr
(28) |
May
(17) |
Jun
(15) |
Jul
(45) |
Aug
(33) |
Sep
(50) |
Oct
(22) |
Nov
(10) |
Dec
(21) |
2012 |
Jan
(33) |
Feb
(24) |
Mar
(36) |
Apr
(60) |
May
(60) |
Jun
(43) |
Jul
(114) |
Aug
(19) |
Sep
(35) |
Oct
(24) |
Nov
(64) |
Dec
(12) |
2013 |
Jan
(54) |
Feb
(58) |
Mar
(51) |
Apr
(46) |
May
(21) |
Jun
(29) |
Jul
(25) |
Aug
(25) |
Sep
(13) |
Oct
(7) |
Nov
(14) |
Dec
(27) |
2014 |
Jan
(10) |
Feb
(7) |
Mar
(16) |
Apr
(14) |
May
(19) |
Jun
(8) |
Jul
(15) |
Aug
(11) |
Sep
(5) |
Oct
(11) |
Nov
(11) |
Dec
(4) |
2015 |
Jan
(52) |
Feb
(27) |
Mar
(22) |
Apr
(17) |
May
(2) |
Jun
(2) |
Jul
(2) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(2) |
Dec
|
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(3) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(2) |
Jun
(2) |
Jul
(2) |
Aug
(2) |
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
(3) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <mg...@us...> - 2006-11-02 21:42:03
|
Revision: 180 http://svn.sourceforge.net/obo/?rev=180&view=rev Author: mgibson Date: 2006-11-02 13:41:54 -0800 (Thu, 02 Nov 2006) Log Message: ----------- took out ctrl-Ms Modified Paths: -------------- phenote/trunk/src/java/phenote/servlet/PhenoteBean.java phenote/trunk/src/java/phenote/servlet/PhenoteController.java phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java Modified: phenote/trunk/src/java/phenote/servlet/PhenoteBean.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteBean.java 2006-11-02 18:29:54 UTC (rev 179) +++ phenote/trunk/src/java/phenote/servlet/PhenoteBean.java 2006-11-02 21:41:54 UTC (rev 180) @@ -1,101 +1,102 @@ -package phenote.servlet; - -import org.apache.commons.lang.StringUtils; - -/** - * This is the main form bean that contains all request parameters. - * Spring populates these attributes automatically and make them available - * in the controller class. - */ -public class PhenoteBean { - - private String userInput; - private String qualityInput; - private String entityInput; - private String ontologyName; - private String termId; - private String field; - - private String ajaxList; - - public boolean isTermCompletionRequest() { - if (!StringUtils.isEmpty(userInput)) - return true; - if (!StringUtils.isEmpty(qualityInput)) - return true; - return !StringUtils.isEmpty(entityInput); - - } - - public String getTermCompletionTerm() { - if (!StringUtils.isEmpty(userInput)) - return userInput; - if (!StringUtils.isEmpty(qualityInput)) - return qualityInput; - if (!StringUtils.isEmpty(entityInput)) - return entityInput; - - return null; - } - - public boolean isTermInfoRequest() { - return !StringUtils.isEmpty(termId); - } - - public String getUserInput() { - return userInput; - } - - public void setUserInput(String userInput) { - this.userInput = userInput; - } - - public String getQualityInput() { - return qualityInput; - } - - public void setQualityInput(String qualityInput) { - this.qualityInput = qualityInput; - } - - public String getEntityInput() { - return entityInput; - } - - public void setEntityInput(String entityInput) { - this.entityInput = entityInput; - } - - public String getOntologyName() { - return ontologyName; - } - - public void setOntologyName(String ontologyName) { - this.ontologyName = ontologyName; - } - - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - public String getAjaxList() { - return ajaxList; - } - - public void setAjaxList(String ajaxList) { - this.ajaxList = ajaxList; - } - - public String getTermId() { - return termId; - } - - public void setTermId(String termId) { - this.termId = termId; - } - -} +package phenote.servlet; + +import org.apache.commons.lang.StringUtils; + +/** + * This is the main form bean that contains all request parameters. + * Spring populates these attributes automatically and make them available + * in the controller class. + */ +public class PhenoteBean { + + private String userInput; + private String qualityInput; + private String entityInput; + private String ontologyName; + private String termId; + private String field; + + private String ajaxList; + + public boolean isTermCompletionRequest() { + if (!StringUtils.isEmpty(userInput)) + return true; + if (!StringUtils.isEmpty(qualityInput)) + return true; + return !StringUtils.isEmpty(entityInput); + + } + + public String getTermCompletionTerm() { + if (!StringUtils.isEmpty(userInput)) + return userInput; + if (!StringUtils.isEmpty(qualityInput)) + return qualityInput; + if (!StringUtils.isEmpty(entityInput)) + return entityInput; + + return null; + } + + public boolean isTermInfoRequest() { + return !StringUtils.isEmpty(termId); + } + + public String getUserInput() { + return userInput; + } + + public void setUserInput(String userInput) { + this.userInput = userInput; + } + + public String getQualityInput() { + return qualityInput; + } + + public void setQualityInput(String qualityInput) { + this.qualityInput = qualityInput; + } + + public String getEntityInput() { + return entityInput; + } + + public void setEntityInput(String entityInput) { + this.entityInput = entityInput; + } + + public String getOntologyName() { + return ontologyName; + } + + public void setOntologyName(String ontologyName) { + this.ontologyName = ontologyName; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public String getAjaxList() { + return ajaxList; + } + + public void setAjaxList(String ajaxList) { + this.ajaxList = ajaxList; + } + + public String getTermId() { + return termId; + } + + public void setTermId(String termId) { + this.termId = termId; + } + +} + Modified: phenote/trunk/src/java/phenote/servlet/PhenoteController.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2006-11-02 18:29:54 UTC (rev 179) +++ phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2006-11-02 21:41:54 UTC (rev 180) @@ -1,155 +1,156 @@ package phenote.servlet; -import org.apache.log4j.Logger; -import org.springframework.validation.BindException; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.AbstractCommandController; -import org.geneontology.oboedit.datamodel.OBOClass; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import phenote.gui.field.CompletionTerm; -import phenote.gui.field.CompListSearcher; -import phenote.gui.field.SearchParamsI; -import phenote.datamodel.OntologyException; -import phenote.datamodel.Ontology; -import phenote.datamodel.OntologyManager; -import phenote.util.HtmlUtil; - -import java.util.Vector; - -/** - * The main controller that receives Ajax ontology requests. - */ -public class PhenoteController extends AbstractCommandController { - - private static final Logger LOG = Logger.getLogger(PhenoteController.class); - - public PhenoteController() { - setCommandClass(PhenoteBean.class); - } - - protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, - BindException errors) throws Exception { - PhenoteBean form = (PhenoteBean) command; - String ontologyName = form.getOntologyName(); - String field = form.getField(); - if (form.isTermCompletionRequest()) { - String userInput = form.getTermCompletionTerm(); - LOG.info("ontology: " + ontologyName); - LOG.info("param entityInput: " + userInput); - LOG.info("Field entity: " + field); - - form.setAjaxList(getCompletionList(userInput, ontologyName, field)); - LOG.debug(form.getAjaxList()); - } else if (form.isTermInfoRequest()) { - String termId = form.getTermId(); - LOG.debug("doGet term info param: " + termId + " ont " + ontologyName); - try { - Ontology ont = getOntology(ontologyName); - OBOClass oboClass = ont.getOboClass(termId); - String termInfo = HtmlUtil.termInfo(oboClass); - LOG.debug("term info " + termInfo.substring(0,60)); - String termInfoObo = HtmlUtil.termInfo(oboClass, ontologyName, field); - form.setAjaxList(termInfoObo); - } - catch (OntologyException e) { - LOG.error(e.getMessage(), e); - } - } - return new ModelAndView("ajax", "formBean", form); - } - - - /** - * ToDo: Need to cleanup this comment. - * List<String>? String[]? or String htmlLiString? - * for now just return html ul-li list w onmouseover - * userInput is what user has typed which terms will be queried for - * ontol is the name of the ontology that user is querying - * field is the gui field user is querying (which may have multiple ontols) - * if ontologyy not found actually returns error string saying as much - why not - * - * @param userInput - * @param ontologyName - * @param field - */ - private String getCompletionList(String userInput, String ontologyName, String field) { - StringBuffer sb = new StringBuffer("<ul>"); - try { - Vector<CompletionTerm> v = getCompListSearcher(ontologyName).getStringMatchTerms(userInput); - //Vector<OBOClass> v = ontology.getStringMatchTerms(userInput, getSearchParams()); - for (CompletionTerm ct : v) - sb.append(makeCompListHtmlItem(ct, ontologyName, field)); - } - catch (OntologyException e) { - sb.append(e.getMessage()); - } - sb.append("</ul>"); - return sb.toString(); - } - - private Object makeCompListHtmlItem(CompletionTerm term, String ontol, String field) { - String id = term.getID(), name = term.getName(); - // pass in id, name & ontology - name for setting field on UseTerm - StringBuffer info = dq(fn("getTermInfo", new String[]{id, name, ontol, field})); - //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; - return "<li onmouseover=" + info + " id=" + q(id) + " " + - "onclick=" + info + ">" + name + "</li>\n"; - } - - private CompListSearcher getCompListSearcher(String ontologyName) throws OntologyException { - return new CompListSearcher(getOntology(ontologyName), getSearchParams()); - } - - /** - * throws ex if ontolName not found - */ - private Ontology getOntology(String ontolName) throws OntologyException { - return OntologyManager.inst().getOntologyForName(ontolName); - } - - private static String q(String s) { - return "'" + s + "'"; - } - - /** - * for now search params hard wired - eventually from buttons on web page - */ - private SearchParamsI getSearchParams() { - return new HardWiredSearchParams(); - } - - private static StringBuffer dq(StringBuffer sb) { - return new StringBuffer("\"" + sb + "\""); - } - - private static StringBuffer fn(String fnName, String[] params) { - return HtmlUtil.fn(fnName, params); - } - - private class HardWiredSearchParams implements SearchParamsI { - public boolean searchTerms() { - return true; - } - - public boolean searchSynonyms() { - return false; // --> true - } - - public boolean searchDefinitions() { - return false; // ?? w [def]?? - } - - /** - * Whether to include obsoletes in searching terms, syns, & definitions - * This should be in conjunction with the other 3 - */ - public boolean searchObsoletes() { - return false; // --> true w [obs], disallow selection - } - } - - -} +import org.apache.log4j.Logger; +import org.springframework.validation.BindException; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.AbstractCommandController; +import org.geneontology.oboedit.datamodel.OBOClass; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import phenote.gui.field.CompletionTerm; +import phenote.gui.field.CompListSearcher; +import phenote.gui.field.SearchParamsI; +import phenote.datamodel.OntologyException; +import phenote.datamodel.Ontology; +import phenote.datamodel.OntologyManager; +import phenote.util.HtmlUtil; + +import java.util.Vector; + +/** + * The main controller that receives Ajax ontology requests. + */ +public class PhenoteController extends AbstractCommandController { + + private static final Logger LOG = Logger.getLogger(PhenoteController.class); + + public PhenoteController() { + setCommandClass(PhenoteBean.class); + } + + protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, + BindException errors) throws Exception { + PhenoteBean form = (PhenoteBean) command; + String ontologyName = form.getOntologyName(); + String field = form.getField(); + if (form.isTermCompletionRequest()) { + String userInput = form.getTermCompletionTerm(); + LOG.info("ontology: " + ontologyName); + LOG.info("param entityInput: " + userInput); + LOG.info("Field entity: " + field); + + form.setAjaxList(getCompletionList(userInput, ontologyName, field)); + LOG.debug(form.getAjaxList()); + } else if (form.isTermInfoRequest()) { + String termId = form.getTermId(); + LOG.debug("doGet term info param: " + termId + " ont " + ontologyName); + try { + Ontology ont = getOntology(ontologyName); + OBOClass oboClass = ont.getOboClass(termId); + String termInfo = HtmlUtil.termInfo(oboClass); + LOG.debug("term info " + termInfo.substring(0,60)); + String termInfoObo = HtmlUtil.termInfo(oboClass, ontologyName, field); + form.setAjaxList(termInfoObo); + } + catch (OntologyException e) { + LOG.error(e.getMessage(), e); + } + } + return new ModelAndView("ajax", "formBean", form); + } + + + /** + * ToDo: Need to cleanup this comment. + * List<String>? String[]? or String htmlLiString? + * for now just return html ul-li list w onmouseover + * userInput is what user has typed which terms will be queried for + * ontol is the name of the ontology that user is querying + * field is the gui field user is querying (which may have multiple ontols) + * if ontologyy not found actually returns error string saying as much - why not + * + * @param userInput + * @param ontologyName + * @param field + */ + private String getCompletionList(String userInput, String ontologyName, String field) { + StringBuffer sb = new StringBuffer("<ul>"); + try { + Vector<CompletionTerm> v = getCompListSearcher(ontologyName).getStringMatchTerms(userInput); + //Vector<OBOClass> v = ontology.getStringMatchTerms(userInput, getSearchParams()); + for (CompletionTerm ct : v) + sb.append(makeCompListHtmlItem(ct, ontologyName, field)); + } + catch (OntologyException e) { + sb.append(e.getMessage()); + } + sb.append("</ul>"); + return sb.toString(); + } + + private Object makeCompListHtmlItem(CompletionTerm term, String ontol, String field) { + String id = term.getID(), name = term.getName(); + // pass in id, name & ontology - name for setting field on UseTerm + StringBuffer info = dq(fn("getTermInfo", new String[]{id, name, ontol, field})); + //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; + return "<li onmouseover=" + info + " id=" + q(id) + " " + + "onclick=" + info + ">" + name + "</li>\n"; + } + + private CompListSearcher getCompListSearcher(String ontologyName) throws OntologyException { + return new CompListSearcher(getOntology(ontologyName), getSearchParams()); + } + + /** + * throws ex if ontolName not found + */ + private Ontology getOntology(String ontolName) throws OntologyException { + return OntologyManager.inst().getOntologyForName(ontolName); + } + + private static String q(String s) { + return "'" + s + "'"; + } + + /** + * for now search params hard wired - eventually from buttons on web page + */ + private SearchParamsI getSearchParams() { + return new HardWiredSearchParams(); + } + + private static StringBuffer dq(StringBuffer sb) { + return new StringBuffer("\"" + sb + "\""); + } + + private static StringBuffer fn(String fnName, String[] params) { + return HtmlUtil.fn(fnName, params); + } + + private class HardWiredSearchParams implements SearchParamsI { + public boolean searchTerms() { + return true; + } + + public boolean searchSynonyms() { + return false; // --> true + } + + public boolean searchDefinitions() { + return false; // ?? w [def]?? + } + + /** + * Whether to include obsoletes in searching terms, syns, & definitions + * This should be in conjunction with the other 3 + */ + public boolean searchObsoletes() { + return false; // --> true w [obs], disallow selection + } + } + + +} + Modified: phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java 2006-11-02 18:29:54 UTC (rev 179) +++ phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java 2006-11-02 21:41:54 UTC (rev 180) @@ -1,30 +1,31 @@ -package phenote.servlet; - -/** - * This contains configuration parameters pertaining to the web application only. - */ -public class PhenoteWebConfiguration { - - private String webRoot; - private static PhenoteWebConfiguration instance; - - private PhenoteWebConfiguration(){ - - } - - public static PhenoteWebConfiguration getInstance(){ - if(instance == null){ - instance = new PhenoteWebConfiguration(); - } - return instance; - } - - - public String getWebRoot() { - return webRoot; - } - - public void setWebRoot(String webRoot) { - this.webRoot = webRoot; - } -} +package phenote.servlet; + +/** + * This contains configuration parameters pertaining to the web application only. + */ +public class PhenoteWebConfiguration { + + private String webRoot; + private static PhenoteWebConfiguration instance; + + private PhenoteWebConfiguration(){ + + } + + public static PhenoteWebConfiguration getInstance(){ + if(instance == null){ + instance = new PhenoteWebConfiguration(); + } + return instance; + } + + + public String getWebRoot() { + return webRoot; + } + + public void setWebRoot(String webRoot) { + this.webRoot = webRoot; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-11-02 18:30:07
|
Revision: 179 http://svn.sourceforge.net/obo/?rev=179&view=rev Author: mgibson Date: 2006-11-02 10:29:54 -0800 (Thu, 02 Nov 2006) Log Message: ----------- added ODA.initialize() as syntactic sugar for getInstance call the first time - all it does is call getInstance() which then initializes ontologies if not already initialized - just more intuitive than call getInstance to do intialization thats all - per christian comment Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/main/Phenote.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-11-02 18:28:53 UTC (rev 178) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-11-02 18:29:54 UTC (rev 179) @@ -55,6 +55,11 @@ return singleton; } + /** just calls getInstance - but more intuitive for initialization */ + public static synchronized void initialize() { + getInstance(); + } + private void initOntologies() { // to prevent reload during init , maybe dont need with synchronization? initializingOntologies = true; Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-11-02 18:28:53 UTC (rev 178) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-11-02 18:29:54 UTC (rev 179) @@ -82,7 +82,7 @@ public void initOntologies() { //OntologyDataAdapter oda = new OntologyDataAdapter(); // singleton? // loads up OntologyManager - non intuitive? - OntologyDataAdapter.getInstance(); + OntologyDataAdapter.initialize(); } private void loadFromCommandLine() { Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-11-02 18:28:53 UTC (rev 178) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-11-02 18:29:54 UTC (rev 179) @@ -47,8 +47,8 @@ } // Ensure the Ontologies are read during start up. This takes a while and should be done // before a different client calls and has to wait. - // ToDo: Shall we create a new method called OntologyDataAdapter.start()? - OntologyDataAdapter.getInstance(); + // ToDo: Shall we create a new method called OntologyDataAdapter.start()? YES + OntologyDataAdapter.initialize(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2006-11-02 18:28:56
|
Revision: 178 http://svn.sourceforge.net/obo/?rev=178&view=rev Author: cmpich Date: 2006-11-02 10:28:53 -0800 (Thu, 02 Nov 2006) Log Message: ----------- added missing test class Added Paths: ----------- phenote/trunk/src/java/test/phenote/util/FileUtilTest.java Added: phenote/trunk/src/java/test/phenote/util/FileUtilTest.java =================================================================== --- phenote/trunk/src/java/test/phenote/util/FileUtilTest.java (rev 0) +++ phenote/trunk/src/java/test/phenote/util/FileUtilTest.java 2006-11-02 18:28:53 UTC (rev 178) @@ -0,0 +1,115 @@ +package phenote.util; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import java.io.File; +import java.io.IOException; + +/** + * Unit test class for FileUtil. + */ +public class FileUtilTest extends TestCase { + + private static final File testArchiveDir = new File("src" + FileUtil.FILE_SEPARATOR + + "java" + FileUtil.FILE_SEPARATOR + + "test", "test-archive-dir"); + private static final File testLoadDirectory = new File("src" + FileUtil.FILE_SEPARATOR + + "java" + FileUtil.FILE_SEPARATOR + + "test", "test-load-dir"); + private File testLoadFile; + private File testPurgeFile; + + public static void main(String args[]) { + TestRunner.run(suite()); + } + + public static Test suite() { + return new TestSuite(FileUtilTest.class); + } + + protected void setUp() { + setTestDirectories(); + } + + protected void tearDown() { + cleanupTestFilesStructure(); + } + + /** + * Create a single file and archive it. Make sure it moved into the archive directory. + */ + public void testArchiveFile() { + File archivedFile = FileUtil.archiveFile(testLoadFile, testArchiveDir); + File[] files = testArchiveDir.listFiles(); + assertEquals("Number of files", 1, files.length); + assertEquals("File Name", archivedFile.getName(), files[0].getName()); + assertTrue("Original File still exists", testLoadFile.exists()); + } + + /** + * Create a single file and archive it. Make sure it moved into the archive directory. + * Sleep for a second and then archive another file and then purge the first file while the + * second file does not get purged. + */ + public void testPurgeArchiveFile() { + File archivedFile = FileUtil.archiveFile(testLoadFile, testArchiveDir); + File[] files = testArchiveDir.listFiles(); + assertEquals("Number of files", 1, files.length); + assertEquals("File Name", archivedFile.getName(), files[0].getName()); + assertTrue("Original File still exists", testLoadFile.exists()); + + // create the second file and wait a second before archiving it. + testPurgeFile = new File(testLoadDirectory, "test-file-two.txt"); + try { + Thread.sleep(1000); + testPurgeFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + + archivedFile = FileUtil.archiveFile(testPurgeFile, testArchiveDir); + files = testArchiveDir.listFiles(); + assertEquals("Number of files", 2, files.length); + FileUtil.purgeArchiveDirectory(testArchiveDir, 990); + + files = testArchiveDir.listFiles(); + assertEquals("Number of files", 1, files.length); + assertEquals("File Name", archivedFile.getName(), files[0].getName()); + + } + + /** + * Create the test directories before the tests are run. + */ + private void setTestDirectories() { + testLoadDirectory.mkdir(); + + testLoadFile = new File(testLoadDirectory, "test-file-one.txt"); + testPurgeFile = new File(testLoadDirectory, "test-file-two.txt"); + try { + testLoadFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Remove test directories after the tests are done. + */ + private void cleanupTestFilesStructure() { + testLoadFile.delete(); + testPurgeFile.delete(); + testLoadDirectory.delete(); + File[] files = testArchiveDir.listFiles(); + for (File file : files) { + file.delete(); + } + testArchiveDir.delete(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2006-11-02 18:20:38
|
Revision: 177 http://svn.sourceforge.net/obo/?rev=177&view=rev Author: cmpich Date: 2006-11-02 10:20:29 -0800 (Thu, 02 Nov 2006) Log Message: ----------- added missing class Added Paths: ----------- phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java Added: phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java (rev 0) +++ phenote/trunk/src/java/phenote/servlet/PhenoteWebConfiguration.java 2006-11-02 18:20:29 UTC (rev 177) @@ -0,0 +1,30 @@ +package phenote.servlet; + +/** + * This contains configuration parameters pertaining to the web application only. + */ +public class PhenoteWebConfiguration { + + private String webRoot; + private static PhenoteWebConfiguration instance; + + private PhenoteWebConfiguration(){ + + } + + public static PhenoteWebConfiguration getInstance(){ + if(instance == null){ + instance = new PhenoteWebConfiguration(); + } + return instance; + } + + + public String getWebRoot() { + return webRoot; + } + + public void setWebRoot(String webRoot) { + this.webRoot = webRoot; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2006-11-02 17:45:55
|
Revision: 176 http://svn.sourceforge.net/obo/?rev=176&view=rev Author: cmpich Date: 2006-11-02 09:45:28 -0800 (Thu, 02 Nov 2006) Log Message: ----------- Added Spring framework Added Quartz scheduler Refactored servlets to make use of spring web API Modified Paths: -------------- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java phenote/trunk/src/java/phenote/util/FileUtil.java phenote/trunk/src/web/WEB-INF/web.xml phenote/trunk/src/web/html/ncbo.html phenote/trunk/src/web/javascript/ncbo-term-info.js Added Paths: ----------- phenote/trunk/jars/commons-lang-2.1.jar phenote/trunk/jars/commons-logging-1.0.4.jar phenote/trunk/jars/quartz-1.5.2.jar phenote/trunk/jars/spring.jar phenote/trunk/jars/standard-1.1.jar phenote/trunk/src/java/phenote/jobs/ phenote/trunk/src/java/phenote/jobs/OntologyUpdateJob.java phenote/trunk/src/java/phenote/servlet/PhenoteBean.java phenote/trunk/src/java/phenote/servlet/PhenoteController.java phenote/trunk/src/java/test/phenote/UnitTests.java phenote/trunk/src/java/test/phenote/util/ phenote/trunk/src/web/WEB-INF/jsp/ phenote/trunk/src/web/WEB-INF/jsp/ajax.jsp phenote/trunk/src/web/WEB-INF/phenote-servlet.xml phenote/trunk/src/web/html/ajax-test.html Property Changed: ---------------- phenote/trunk/src/web/WEB-INF/web.xml Added: phenote/trunk/jars/commons-lang-2.1.jar =================================================================== (Binary files differ) Property changes on: phenote/trunk/jars/commons-lang-2.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/jars/commons-logging-1.0.4.jar =================================================================== (Binary files differ) Property changes on: phenote/trunk/jars/commons-logging-1.0.4.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/jars/quartz-1.5.2.jar =================================================================== (Binary files differ) Property changes on: phenote/trunk/jars/quartz-1.5.2.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/jars/spring.jar =================================================================== (Binary files differ) Property changes on: phenote/trunk/jars/spring.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/jars/standard-1.1.jar =================================================================== (Binary files differ) Property changes on: phenote/trunk/jars/standard-1.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/src/java/phenote/jobs/OntologyUpdateJob.java =================================================================== --- phenote/trunk/src/java/phenote/jobs/OntologyUpdateJob.java (rev 0) +++ phenote/trunk/src/java/phenote/jobs/OntologyUpdateJob.java 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,93 @@ +package phenote.jobs; + +import org.apache.log4j.Logger; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.scheduling.quartz.QuartzJobBean; +import phenote.util.FileUtil; +import phenote.datamodel.Ontology; +import phenote.datamodel.OntologyManager; +import phenote.dataadapter.OntologyDataAdapter; +import phenote.servlet.PhenoteWebConfiguration; + +import java.io.File; +import java.util.Date; + +/** + * Job that reloads and archives a specified ontology. This job is scheduled via Quartz. + * The job is defined in the spring configuration file. + */ +public class OntologyUpdateJob extends QuartzJobBean { + + public static final Logger LOG = Logger.getLogger(OntologyUpdateJob.class); + public static final long MILLISECONDS_PER_DAY = (24 * 60 * 60 * 1000); + + // set by spring + private String ontologyName; + private String archiveDirectory; + private double purgePeriodInDays; + + + protected void executeInternal(JobExecutionContext context) throws JobExecutionException { + LOG.info("Started Ontology Update Job"); + + try { + Ontology ontology = OntologyManager.inst().getOntologyForName(ontologyName); + File newFile = newOntologyFile(ontology); + if (newFile != null) { + OntologyDataAdapter ontReader = OntologyDataAdapter.getInstance(); + ontReader.reloadOntology(ontology); + + File archiveFile = FileUtil.archiveFile(newFile, PhenoteWebConfiguration.getInstance().getWebRoot(), archiveDirectory); + long purgePeriodInMilliseconds = (long) (purgePeriodInDays * MILLISECONDS_PER_DAY ); + FileUtil.purgeArchiveDirectory(archiveFile.getParentFile(), purgePeriodInMilliseconds); + } + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + } + + /* + * Retrieve the new ontology file if available. + * It checks the time stamps of the new file and the file + * from which it was loaded (save in the Ontology object) + */ + private File newOntologyFile(Ontology ontology) { + String fileName = ontology.getSource(); + File file = new File(fileName); + long timestamp = file.lastModified(); + long timestampOldFile = ontology.getTimestamp(); + if (timestamp > timestampOldFile) { + LOG.debug("New File " + file.getAbsolutePath() + " found. "); + return file; + } else { + Date date = new Date(timestampOldFile); + LOG.debug("The file " + file.getAbsolutePath() + " has not changed since the last load: " + date); + return null; + } + } + + public String getOntologyName() { + return ontologyName; + } + + public void setOntologyName(String ontologyName) { + this.ontologyName = ontologyName; + } + + public String getArchiveDirectory() { + return archiveDirectory; + } + + public void setArchiveDirectory(String archiveDirectory) { + this.archiveDirectory = archiveDirectory; + } + + public double getPurgePeriodInDays() { + return purgePeriodInDays; + } + + public void setPurgePeriodInDays(double purgePeriodInDays) { + this.purgePeriodInDays = purgePeriodInDays; + } +} Added: phenote/trunk/src/java/phenote/servlet/PhenoteBean.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteBean.java (rev 0) +++ phenote/trunk/src/java/phenote/servlet/PhenoteBean.java 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,101 @@ +package phenote.servlet; + +import org.apache.commons.lang.StringUtils; + +/** + * This is the main form bean that contains all request parameters. + * Spring populates these attributes automatically and make them available + * in the controller class. + */ +public class PhenoteBean { + + private String userInput; + private String qualityInput; + private String entityInput; + private String ontologyName; + private String termId; + private String field; + + private String ajaxList; + + public boolean isTermCompletionRequest() { + if (!StringUtils.isEmpty(userInput)) + return true; + if (!StringUtils.isEmpty(qualityInput)) + return true; + return !StringUtils.isEmpty(entityInput); + + } + + public String getTermCompletionTerm() { + if (!StringUtils.isEmpty(userInput)) + return userInput; + if (!StringUtils.isEmpty(qualityInput)) + return qualityInput; + if (!StringUtils.isEmpty(entityInput)) + return entityInput; + + return null; + } + + public boolean isTermInfoRequest() { + return !StringUtils.isEmpty(termId); + } + + public String getUserInput() { + return userInput; + } + + public void setUserInput(String userInput) { + this.userInput = userInput; + } + + public String getQualityInput() { + return qualityInput; + } + + public void setQualityInput(String qualityInput) { + this.qualityInput = qualityInput; + } + + public String getEntityInput() { + return entityInput; + } + + public void setEntityInput(String entityInput) { + this.entityInput = entityInput; + } + + public String getOntologyName() { + return ontologyName; + } + + public void setOntologyName(String ontologyName) { + this.ontologyName = ontologyName; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public String getAjaxList() { + return ajaxList; + } + + public void setAjaxList(String ajaxList) { + this.ajaxList = ajaxList; + } + + public String getTermId() { + return termId; + } + + public void setTermId(String termId) { + this.termId = termId; + } + +} Added: phenote/trunk/src/java/phenote/servlet/PhenoteController.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteController.java (rev 0) +++ phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,155 @@ +package phenote.servlet; + +import org.apache.log4j.Logger; +import org.springframework.validation.BindException; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.AbstractCommandController; +import org.geneontology.oboedit.datamodel.OBOClass; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import phenote.gui.field.CompletionTerm; +import phenote.gui.field.CompListSearcher; +import phenote.gui.field.SearchParamsI; +import phenote.datamodel.OntologyException; +import phenote.datamodel.Ontology; +import phenote.datamodel.OntologyManager; +import phenote.util.HtmlUtil; + +import java.util.Vector; + +/** + * The main controller that receives Ajax ontology requests. + */ +public class PhenoteController extends AbstractCommandController { + + private static final Logger LOG = Logger.getLogger(PhenoteController.class); + + public PhenoteController() { + setCommandClass(PhenoteBean.class); + } + + protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, + BindException errors) throws Exception { + PhenoteBean form = (PhenoteBean) command; + String ontologyName = form.getOntologyName(); + String field = form.getField(); + if (form.isTermCompletionRequest()) { + String userInput = form.getTermCompletionTerm(); + LOG.info("ontology: " + ontologyName); + LOG.info("param entityInput: " + userInput); + LOG.info("Field entity: " + field); + + form.setAjaxList(getCompletionList(userInput, ontologyName, field)); + LOG.debug(form.getAjaxList()); + } else if (form.isTermInfoRequest()) { + String termId = form.getTermId(); + LOG.debug("doGet term info param: " + termId + " ont " + ontologyName); + try { + Ontology ont = getOntology(ontologyName); + OBOClass oboClass = ont.getOboClass(termId); + String termInfo = HtmlUtil.termInfo(oboClass); + LOG.debug("term info " + termInfo.substring(0,60)); + String termInfoObo = HtmlUtil.termInfo(oboClass, ontologyName, field); + form.setAjaxList(termInfoObo); + } + catch (OntologyException e) { + LOG.error(e.getMessage(), e); + } + } + return new ModelAndView("ajax", "formBean", form); + } + + + /** + * ToDo: Need to cleanup this comment. + * List<String>? String[]? or String htmlLiString? + * for now just return html ul-li list w onmouseover + * userInput is what user has typed which terms will be queried for + * ontol is the name of the ontology that user is querying + * field is the gui field user is querying (which may have multiple ontols) + * if ontologyy not found actually returns error string saying as much - why not + * + * @param userInput + * @param ontologyName + * @param field + */ + private String getCompletionList(String userInput, String ontologyName, String field) { + StringBuffer sb = new StringBuffer("<ul>"); + try { + Vector<CompletionTerm> v = getCompListSearcher(ontologyName).getStringMatchTerms(userInput); + //Vector<OBOClass> v = ontology.getStringMatchTerms(userInput, getSearchParams()); + for (CompletionTerm ct : v) + sb.append(makeCompListHtmlItem(ct, ontologyName, field)); + } + catch (OntologyException e) { + sb.append(e.getMessage()); + } + sb.append("</ul>"); + return sb.toString(); + } + + private Object makeCompListHtmlItem(CompletionTerm term, String ontol, String field) { + String id = term.getID(), name = term.getName(); + // pass in id, name & ontology - name for setting field on UseTerm + StringBuffer info = dq(fn("getTermInfo", new String[]{id, name, ontol, field})); + //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; + return "<li onmouseover=" + info + " id=" + q(id) + " " + + "onclick=" + info + ">" + name + "</li>\n"; + } + + private CompListSearcher getCompListSearcher(String ontologyName) throws OntologyException { + return new CompListSearcher(getOntology(ontologyName), getSearchParams()); + } + + /** + * throws ex if ontolName not found + */ + private Ontology getOntology(String ontolName) throws OntologyException { + return OntologyManager.inst().getOntologyForName(ontolName); + } + + private static String q(String s) { + return "'" + s + "'"; + } + + /** + * for now search params hard wired - eventually from buttons on web page + */ + private SearchParamsI getSearchParams() { + return new HardWiredSearchParams(); + } + + private static StringBuffer dq(StringBuffer sb) { + return new StringBuffer("\"" + sb + "\""); + } + + private static StringBuffer fn(String fnName, String[] params) { + return HtmlUtil.fn(fnName, params); + } + + private class HardWiredSearchParams implements SearchParamsI { + public boolean searchTerms() { + return true; + } + + public boolean searchSynonyms() { + return false; // --> true + } + + public boolean searchDefinitions() { + return false; // ?? w [def]?? + } + + /** + * Whether to include obsoletes in searching terms, syns, & definitions + * This should be in conjunction with the other 3 + */ + public boolean searchObsoletes() { + return false; // --> true w [obs], disallow selection + } + } + + +} Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-11-02 16:13:23 UTC (rev 175) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-11-02 17:45:28 UTC (rev 176) @@ -1,311 +1,55 @@ package phenote.servlet; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Date; -import java.util.Vector; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletRequest; - -import org.geneontology.oboedit.datamodel.OBOClass; import org.apache.log4j.Logger; - -import phenote.datamodel.CharField; -import phenote.datamodel.CharFieldEnum; -import phenote.datamodel.Ontology; -import phenote.datamodel.OntologyException; -import phenote.datamodel.OntologyManager; -// hmmm bad to ref gui? or is servlet gui-esque? or move search to own package? -import phenote.gui.field.CompletionTerm; -import phenote.gui.field.CompListSearcher; -import phenote.gui.field.SearchParamsI; -import phenote.util.HtmlUtil; +import org.apache.commons.lang.StringUtils; +import org.springframework.web.servlet.DispatcherServlet; import phenote.config.Config; import phenote.config.ConfigException; -import phenote.main.Phenote; import phenote.dataadapter.OntologyDataAdapter; +import phenote.util.HtmlUtil; -public class PhenoteServlet extends HttpServlet { +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; - private static final String CONFIG_FILE_PARAM = "configuration-file"; - // PhenoteServlet.class is the distinct name for this logger +public class PhenoteServlet extends DispatcherServlet { + + private static final String CONFIG_FILE_PARAM = "configuration-file"; private static final Logger LOG = Logger.getLogger(PhenoteServlet.class); - //private String configurationFileName; not sure needs to be var - private Date initDate; - //private Phenote phenote; - - /** - * if <load-on-startup>1</load-on-startup> is in web.xml then init will - * happen when web server started (or if code recompiled) - so this is where - * the ontology reading & caching goes - */ - public void init() throws ServletException { - initDate = new Date(); - super.init(); - // makes links for term info - put this method in Phenote? - HtmlUtil.setStandAlone(false); - //phenote = Phenote.getPhenote(); - // from web.xml - String configFile = getInitParameter(CONFIG_FILE_PARAM); - // just in case not in web.xml - if (configFile == null || configFile.equals("")) - configFile = "/initial-zfin.cfg"; - //boolean DEBUG = true; if (DEBUG) configFile = "/fiddle.cfg"; - try { - Config.inst().setConfigFile(configFile); // causes parse of file - } catch (ConfigException e) { - String m = "Error in config file: " + configFile + " " + e.getMessage(); - LOG.error(m); - throw new ServletException(m); // ?? - } - // cheesy - revisit - //String[] args = {"-c","initial-zfin.cfg"}; - //phenote.initConfig(args); // hardwire for now to zfin - //phenote.initOntologies(); - // loads ontologies up - non intuitive? - OntologyDataAdapter.getInstance(); - // this is not running as a separate thread - investigate -// System.out.println("ontologies loaded - starting file checking thread"); -// OntologyFileCheckThread ofct = new OntologyFileCheckThread(); -// ofct.start(); // is this not running as threaded? -// System.out.println("file thread launched - moving on"); - } - - - /** - * AUTO COMPLETE REQUEST - * this should be done in java server faces/pages(?), post comes from ajax - * autocompleter on typing in stuff. prints html ul list to response: - <ul> - <li onmouseover=getTermInfo('id','name','ontol','field') id='id' - onclick=selectTerm('name','field') > termName </li> - <li ... - </ul> - */ - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - // dont know where this goes??? - LOG.debug("servlet doPost " + new Date()); - LOG.info("is term comp request: " + isTermCompletionRequest(request)); - - PrintWriter out = response.getWriter(); - - if (isTermCompletionRequest(request)) { - String userInput = getTermCompletionParam(request); - LOG.info("ontology? " + getOntologyParamString(request) + " param entityInput? " + getTermCompletionParam(request)); -//ResourceBundle r=ResourceBundle.getBundle("LocalStrings",request.getLocale()); - //Content-Type: text/html; charset=ISO-8859-1 - response.setContentType("text/html"); - //out.println("Content-Type: text/html; charset=ISO-8859-1"); // this messes things up -// String list = "<ul><li onmouseover=\"set_ontology()\" id=\"termId\" "+ -// "onclick=\"set_ontology()\">"+userInput+"</li>\n"+ -// "<li onmouseover=\"set_ontology()\" id=\"termId\" onclick=\"set_ontology()\">"+ -// "test</li>\n<li onmouseover=\"set_ontology()\" id=\"termId\" onclick=\"set_ontology()\">dude</li></ul>"; - String ontol = getOntologyParamString(request); - String field = getFieldParamString(request); - String list = getCompletionList(userInput, ontol, field); - LOG.debug("printing to response writer: " + substring(list, 55) + "..."); - out.println(list); - } - - } - - private boolean isTermCompletionRequest(HttpServletRequest req) { - return getTermCompletionParam(req) != null; - } - - /** - * this should be renamed from unintuitive "ontologyname" - */ - private String getTermCompletionParam(HttpServletRequest req) { - String par = req.getParameter("userInput"); // new way - if (par == null) - par = req.getParameter("qualityInput"); // for now - pase i think - if (par == null) - par = req.getParameter("entityInput"); - return par; - } - - private String getOntologyParamString(HttpServletRequest req) { - return req.getParameter("ontologyName"); - } - - /** field param string specifies what gui field the request came from - this is - used for UseTermInfo button to populate field from term info */ - private String getFieldParamString(HttpServletRequest req) { - return req.getParameter("field"); - } - - - /** - * TERM INFO request - * i cant tell ya why but term info is done with a get and term completion - * is done with a post - is there rhyme or reason to this? + * Initialization of this servlet upon server startup. + * Happens when <load-on-startup> tag in the web.xml is set to '1'. + * + * @param config + * @throws ServletException */ - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - if (isTermInfoRequest(request)) { - PrintWriter out = response.getWriter(); - String termId = getTermIdFromTermInfoRequest(request); - String ontologyName = getOntologyParamString(request); - String field = getFieldParamString(request); - LOG.debug("doGet term info param: " + termId + " ont " + ontologyName); - try { - Ontology ont = getOntology(ontologyName); // throws ex - OBOClass oboClass = ont.getOboClass(termId); // throws ex - //if (oboClass == null) { - // LOG.error("term info: no obo class found for " + termId); return; } - LOG.debug("term info " + substring(HtmlUtil.termInfo(oboClass), 60)); - out.println(HtmlUtil.termInfo(oboClass, ontologyName,field)); - } - catch (OntologyException e) { - LOG.error(e.getMessage()); - } - } - } + public void init(ServletConfig config) throws ServletException { + super.init(config); + PhenoteWebConfiguration.getInstance().setWebRoot(getServletContext().getRealPath("/")); - private String substring(String s, int sz) { - sz = (s.length() <= sz) ? s.length() : sz; - return s.substring(0, sz); - } + // ToDo: + // makes links for term info - put this method in Phenote? + // Yes, this looks ood in here. Can Phenote get this info from the + // property file? + HtmlUtil.setStandAlone(false); + String configFile = getInitParameter(CONFIG_FILE_PARAM); + // set default value + if (StringUtils.isEmpty(configFile)) + configFile = "/initial-zfin.cfg"; - private boolean isTermInfoRequest(HttpServletRequest req) { - return getTermIdFromTermInfoRequest(req) != null; - } - - private String getTermIdFromTermInfoRequest(HttpServletRequest req) { - return req.getParameter("termId"); - } - - - /** List<String>? String[]? or String htmlLiString? - for now just return html ul-li list w onmouseover - userInput is what user has typed which terms will be queried for - ontol is the name of the ontology that user is querying - field is the gui field user is querying (which may have multiple ontols) - if ontologyy not found actually returns error string saying as much - why not*/ - private String getCompletionList(String userInput,String ontol,String field) { - StringBuffer sb = new StringBuffer("<ul>"); + // ToDo: how do we deal with: file not found? try { - Vector<CompletionTerm> v = getCompListSearcher(ontol).getStringMatchTerms(userInput); - //Vector<OBOClass> v = ontology.getStringMatchTerms(userInput, getSearchParams()); - for (CompletionTerm ct : v) - sb.append(makeCompListHtmlItem(ct, ontol, field)); + Config.inst().setConfigFile(configFile); // causes parse of file + } catch (ConfigException e) { + String errorMessage = "Error in config file: " + configFile + " " + e.getMessage(); + LOG.error(errorMessage, e); + throw new ServletException(errorMessage); // ?? } - catch (OntologyException e) { sb.append(e.getMessage()); } - sb.append("</ul>"); - return sb.toString(); + // Ensure the Ontologies are read during start up. This takes a while and should be done + // before a different client calls and has to wait. + // ToDo: Shall we create a new method called OntologyDataAdapter.start()? + OntologyDataAdapter.getInstance(); } - private CompListSearcher getCompListSearcher(String ontol) throws OntologyException { - return new CompListSearcher(getOntology(ontol),getSearchParams()); - } - - /** - * throws ex if ontolName not found - */ - private Ontology getOntology(String ontolName) throws OntologyException { -// if (ontology == null) { -// LOG.error("failed to get " + ontol + " from ontology manager"); -// //return "ontology retrieval failed"; -// throw new Exception("ontology retrieval failed"); } - return OntologyManager.inst().getOntologyForName(ontolName); - } - -// // for now... -// private Ontology getQualityOntology() { -// for (CharField cf : OntologyManager.inst().getCharFieldList()) -// if (cf.getCharFieldEnum() == CharFieldEnum.QUALITY) -// return cf.getFirstOntology(); -// LOG.error("quality ontology not found in ontology manager"); -// return null; -// } - - private String makeCompListHtmlItem(CompletionTerm term, String ontol,String field) { - String id = term.getID(), name=term.getName(); - String display = term.getCompListDisplayString(); - // pass in id, name & ontology - name for setting field on UseTerm - StringBuffer info = dq(fn("getTermInfo",new String[]{id,name,ontol,field})); - StringBuffer select = dq(fn("selectTerm",new String[]{name,field})); - //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; - return "<li onmouseover=" + info + " id=" + q(id) + " " + - "onclick=" + select + ">" + display + "</li>\n"; - } - - private static StringBuffer fn(String fnName, String[] params) { - return HtmlUtil.fn(fnName,params); - } -// StringBuffer s = new StringBuffer(fnName).append("(").append(q(params[0])); -// for (int i=1; i<params.length; i++) s.append(",").append(q(params[i])); -// s.append(")"); return s; } - - private static StringBuffer dq(StringBuffer sb) { - return new StringBuffer("\""+sb+"\""); - } - - private static StringBuffer q(StringBuffer sb) { - return new StringBuffer("'"+sb+"'"); - } - - private static String q(String s) { - return "'"+s+"'"; - } - - /** - * for now search params hard wired - eventually from buttons on web page - */ - private SearchParamsI getSearchParams() { - return new HardWiredSearchParams(); - } - - private class HardWiredSearchParams implements SearchParamsI { - public boolean searchTerms() { - return true; - } - - public boolean searchSynonyms() { - return true; // --> true - } - - public boolean searchDefinitions() { - return false; // ?? w [def]?? - } - - /** - * Whether to include obsoletes in searching terms, syns, & definitions - * This should be in conjunction with the other 3 - */ - public boolean searchObsoletes() { - return false; // --> true w [obs], disallow selection - } - } - } -// if (ont == null) { -// LOG.error("ERROR: Failed to get ontology for " + ontologyName); return; } -// ---> OntologyDataAdapter - moved to -// /** thread wakes up and checks if theres a new ontology file - if so loads it -// this should go in ontology data adapter... not here and configged */ -// private class OntologyFileCheckThread extends Thread { - -// public void run() { - -// while(true) { -// System.out.println("checking for new files..."); -// // check for files... - -// // sleep in milliseconds - sleep for 5 seconds for now (test) -// try { sleep(5000); } -// catch (InterruptedException e) { System.out.println("interrupted"); } -// } -// } -// } - - - Modified: phenote/trunk/src/java/phenote/util/FileUtil.java =================================================================== --- phenote/trunk/src/java/phenote/util/FileUtil.java 2006-11-02 16:13:23 UTC (rev 175) +++ phenote/trunk/src/java/phenote/util/FileUtil.java 2006-11-02 17:45:28 UTC (rev 176) @@ -1,19 +1,26 @@ package phenote.util; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import java.util.GregorianCalendar; +import java.util.Calendar; +import java.nio.channels.FileChannel; +import java.nio.ByteBuffer; import org.apache.log4j.Logger; public class FileUtil { - //private static final Logger LOG = Logger.getLogger(FileUtil.class); + public static final String FILE_SEPARATOR = System.getProperty("file.separator"); + public static final String DASH = "-"; + public static final String UNDERSCORE = "_"; + public static final String DOT = "."; + private static final Logger LOG = Logger.getLogger(FileUtil.class); + public static URL findUrl(String filename) throws FileNotFoundException { List<URL> possibleUrls = getPossibleUrls(filename); for (URL u : possibleUrls) @@ -55,4 +62,124 @@ return true; } + /** + * This method moves (renames) a given file into an archive directory. + * The file name is changed to include a time stamp. + * + * @param file + * @param archiveFolderPath + * @param archiveFolderName + */ + public static File archiveFile(File file, String archiveFolderPath, String archiveFolderName) { + File dir = new File(archiveFolderPath, archiveFolderName); + return archiveFile(file, dir); + } + + /** + * This method moves (renames) a given file into an archive directory. + * The file name is changed to include a time stamp: + * original file name: <file_name.txt> + * archived file name: <file_name-yyyy-MM-dd_HH_MI_ss.txt> + * + * The archive file is returned. + * The original file is removed. + * The archive directory is created if it does not exist. + * + * @param file file that should be archived + * @param archiveDirectory + * @return File archive file + */ + public static File archiveFile(File file, File archiveDirectory) { + // Create the directory if it does not exist yet. + if (!archiveDirectory.exists()) { + boolean success = archiveDirectory.mkdirs(); + if (!success) + LOG.error("Error while creating the archive directory '" + archiveDirectory.getAbsolutePath()); + } + + GregorianCalendar cal = new GregorianCalendar(); + String fileName = file.getName(); + int indexOfLastDot = fileName.lastIndexOf(DOT); + String extension = fileName.substring(indexOfLastDot + 1); + + StringBuilder archiveFileName = new StringBuilder(file.getName().substring(0, indexOfLastDot)); + archiveFileName.append(DASH); + archiveFileName.append(cal.get(Calendar.YEAR)); + archiveFileName.append(DASH); + archiveFileName.append(cal.get(Calendar.MONTH)); + archiveFileName.append(DASH); + archiveFileName.append(cal.get(Calendar.DAY_OF_MONTH)); + archiveFileName.append(UNDERSCORE); + archiveFileName.append(cal.get(Calendar.HOUR)); + archiveFileName.append(UNDERSCORE); + archiveFileName.append(cal.get(Calendar.MINUTE)); + archiveFileName.append(UNDERSCORE); + archiveFileName.append(cal.get(Calendar.SECOND)); + archiveFileName.append(DOT); + archiveFileName.append(extension); + File archiveFile = new File(archiveDirectory, archiveFileName.toString()); + if (archiveFile.exists()) + LOG.info("Archive file " + archiveFile.getAbsolutePath() + " already exists. Cannot overwrite it."); + else { + boolean success = copyFileIntoArchive(file, archiveFile); + if (!success) + LOG.error("Error while renaming the file '" + file.getAbsolutePath()); + } + return archiveFile; + } + + private static boolean copyFileIntoArchive(File file, File archiveFile) { + boolean success = true; + FileInputStream fis = null; + FileOutputStream fos = null; + try { + fis = new FileInputStream(file); + fos = new FileOutputStream(archiveFile); + FileChannel inChannel = fis.getChannel(); + ByteBuffer buffer = ByteBuffer.allocate(48); + FileChannel outChannel = fos.getChannel(); + while (inChannel.read(buffer) != -1) { + outChannel.write(buffer); + } + fos.close(); + fis.close(); + + } catch (Exception e) { + LOG.error(e.getMessage(), e); + return false; + } finally { + try { + if (fis != null) + fis.close(); + if (fos != null) + fos.close(); + } catch (IOException e) { + LOG.error(e.getMessage(), e); + success = false; + } + } + return success; + } + + + /** + * Purge an archive directory for files that are older than the purge time. + * + * @param archiveDirectory + * @param purgeTime in milliseconds + */ + public static void purgeArchiveDirectory(File archiveDirectory, long purgeTime) { + File[] files = archiveDirectory.listFiles(); + long time = System.currentTimeMillis(); + for (File file : files) { + long fileModified = file.lastModified(); + long fileAge = time - fileModified; + if (fileAge > purgeTime) { + boolean success = file.delete(); + if (!success) + LOG.error("Error while purging archive file '" + file.getAbsolutePath()); + } + } + } + } Added: phenote/trunk/src/java/test/phenote/UnitTests.java =================================================================== --- phenote/trunk/src/java/test/phenote/UnitTests.java (rev 0) +++ phenote/trunk/src/java/test/phenote/UnitTests.java 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,30 @@ +package phenote; + +import junit.framework.TestSuite; +import junit.textui.TestRunner; +import phenote.util.FileUtilTest; + +/** + * This is the master unit test class that runs all registered unit tests (suite). + * Add your new unit test here if it is ready to be included in regular builds. + */ +public class UnitTests extends TestSuite { + + public UnitTests() { + super("Unit Tests"); + } + + public static void main(String args[]) { + TestRunner.run(suite()); + } + + /** + * Add unit test class here to the suite. + */ + public static TestSuite suite() { + TestSuite suite = new TestSuite(); + suite.addTest(FileUtilTest.suite()); + return suite; + } + +} Added: phenote/trunk/src/web/WEB-INF/jsp/ajax.jsp =================================================================== --- phenote/trunk/src/web/WEB-INF/jsp/ajax.jsp (rev 0) +++ phenote/trunk/src/web/WEB-INF/jsp/ajax.jsp 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,6 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> +<html> +<body> +<c:out value="${formBean.ajaxList}" escapeXml="false"/> +</body> +</html> \ No newline at end of file Added: phenote/trunk/src/web/WEB-INF/phenote-servlet.xml =================================================================== --- phenote/trunk/src/web/WEB-INF/phenote-servlet.xml (rev 0) +++ phenote/trunk/src/web/WEB-INF/phenote-servlet.xml 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> + +<beans> + +<!-- + <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> + <property name="mappings"> + <props> + <prop key="/phenote/">main</prop> + </props> + </property> + </bean> +--> + + <bean name="/" class="phenote.servlet.PhenoteController"/> + + <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" > + <property name="prefix"> + <value>/WEB-INF/jsp/</value> + </property> + <property name="suffix"> + <value>.jsp</value> + </property> + </bean> + + <!-- QUARTZ SCHEDULER --> + <bean id="anatomyOntologyReloadJob" class="org.springframework.scheduling.quartz.JobDetailBean"> + <property name="jobClass"> + <value>phenote.jobs.OntologyUpdateJob</value> + </property> + <property name="jobDataAsMap"> + <map> + <entry key="ontologyName"> + <value>ZF</value> + </entry> + <!-- This directory is relative to the webroot --> + <entry key="archiveDirectory"> + <value>archive-ontology</value> + </entry> + <!-- time stated in days (can be a fraction) --> + <entry key="purgePeriodInDays"> + <value>0.0035</value> + </entry> + </map> + </property> + </bean> + + <bean id="cronOntologyTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> + <property name="jobDetail"> + <ref bean="anatomyOntologyReloadJob"/> + </property> + <property name="cronExpression"> + <value>20 * * * * ?</value> + </property> + </bean> + + <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> + <property name="triggers"> + <list> + <ref bean="cronOntologyTrigger"/> + </list> + </property> + </bean> +</beans> \ No newline at end of file Property changes on: phenote/trunk/src/web/WEB-INF/phenote-servlet.xml ___________________________________________________________________ Name: svn:eol-style + native Modified: phenote/trunk/src/web/WEB-INF/web.xml =================================================================== --- phenote/trunk/src/web/WEB-INF/web.xml 2006-11-02 16:13:23 UTC (rev 175) +++ phenote/trunk/src/web/WEB-INF/web.xml 2006-11-02 17:45:28 UTC (rev 176) @@ -5,13 +5,9 @@ <web-app> <servlet> - <servlet-name>Phenote</servlet-name> + <servlet-name>phenote</servlet-name> <servlet-class>phenote.servlet.PhenoteServlet</servlet-class> <init-param> - <param-name>"-Xmx"</param-name> - <param-value>200M</param-value> - </init-param> - <init-param> <param-name>configuration-file</param-name> <param-value>/initial-zfin.cfg</param-value> </init-param> @@ -19,7 +15,12 @@ </servlet> <servlet-mapping> - <servlet-name>Phenote</servlet-name> - <url-pattern>/Phenote</url-pattern> + <servlet-name>phenote</servlet-name> + <url-pattern>/Phenote/*</url-pattern> </servlet-mapping> + + <welcome-file-list> + <welcome-file>html/ncbo.html</welcome-file> + </welcome-file-list> + </web-app> Property changes on: phenote/trunk/src/web/WEB-INF/web.xml ___________________________________________________________________ Name: svn:eol-style + native Added: phenote/trunk/src/web/html/ajax-test.html =================================================================== --- phenote/trunk/src/web/html/ajax-test.html (rev 0) +++ phenote/trunk/src/web/html/ajax-test.html 2006-11-02 17:45:28 UTC (rev 176) @@ -0,0 +1,46 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + +</HEAD> + +<BODY> + + +<form name="termForm" action="/phenote/Phenote/" method="post"> + <div id="ontology" width="20%"> + + Post: + <div style="float: left;" width="20%"> + + <fieldset class="search"> + <br/><br/><br/> + + <label for="entityOntology">Ontology:</label> + <select name="ontologyName" id="entityOntology" + onChange="setEntityOntology(this.options[this.selectedIndex].value);"> + <option value="ZF">AO</option> + <option value="GO">GO</option> + </select> + + <input name="userInput" size="40" type="text" value="neural rod"/> + <label>Entity: </label> + <input name="field" size="40" type="text" value="ENTITY"/> + <br/> + </fieldset> + + </div> + + <input type="submit" value="Submit"/> + + + </div> + + +</form> + +<p></p> +GET: <a href="/phenote/Phenote/?termId=ZFA:0001066&ontologyName=ZF&field=ENTITY"> Get Term Info</a> +</body> +</html> + Modified: phenote/trunk/src/web/html/ncbo.html =================================================================== --- phenote/trunk/src/web/html/ncbo.html 2006-11-02 16:13:23 UTC (rev 175) +++ phenote/trunk/src/web/html/ncbo.html 2006-11-02 17:45:28 UTC (rev 176) @@ -4,7 +4,7 @@ <TITLE> Phenote </TITLE> -<!-- we need some way of parameterizing the root of the web files??? --> +<!-- we need some way of parameterizing the root of the web files??? --> <!-- set in some file somewhere? --> <link href="../css/control.css" type="text/css" rel="stylesheet"> @@ -62,7 +62,7 @@ <label for="entityOntology">Ontology:</label> <select name="entityOntology" id="entityOntology" onChange="setEntityOntology(this.options[this.selectedIndex].value);"> - <option value="AO">AO</option> + <option value="AO">AO</option> <option value="GO">GO</option> </select> @@ -117,14 +117,14 @@ <!-- 'ontologyname_auto_complete', '/phenote-ontology.cgi',{ }) --> <!-- new Ajax.Autocompleter( 'ontologyname', 'ontologyname_auto_complete', '/servlet/PhenoteStub',{ }) --> <!-- new Ajax.Autocompleter( 'ontologyname', 'ontologyname_auto_complete', '/servlet/phenote.servlet.PhenoteServlet',{ }) --> - var complete = new Ajax.Autocompleter( 'qualityInput', 'quality_auto_complete', '../Phenote',{parameters:'ontologyName=quality&field=QUALITY',paramName: "userInput" }) + var complete = new Ajax.Autocompleter( 'qualityInput', 'quality_auto_complete', '../Phenote/',{parameters:'ontologyName=quality&field=QUALITY',paramName: "userInput" }) <!-- complete.options.defaultParams = "ontology=quality"; --> <!-- complete.options.parameters = "ontology=quality"; --> <!-- more params? 'ontology=quality&x=y&...' --> </script> <script type="text/javascript"> - var entityAutoCompleter = new Ajax.Autocompleter( 'entityInput', 'entity_auto_complete', '../Phenote',{parameters:'ontologyName=ZF&field=ENTITY',paramName: "userInput"}) + var entityAutoCompleter = new Ajax.Autocompleter( 'entityInput', 'entity_auto_complete', '../Phenote/',{parameters:'ontologyName=ZF&field=ENTITY',paramName: "userInput"}) </script> @@ -132,16 +132,16 @@ <!-- this is set by ncbo-term-info.js but its unclear what its for is this the datamodel???? --> <input type="hidden" name="termInfoTermId"> <input type="hidden" name="termInfoTermName"> - <!--what input field haas the user most recently moused over terms --> + <!--what input field haas the user most recently moused over terms --> <!-- ENTITY or QUALITY, set by ncbo-term-info.js --> <input type="hidden" name="activeField"> </form> - + <!-- /td --> <!-- td width="80%" --> <div id="termInfo"></div> - <!-- USE TERM BUTTON --> + <!-- USE TERM BUTTON --> <input type="button" value="Use Term" Modified: phenote/trunk/src/web/javascript/ncbo-term-info.js =================================================================== --- phenote/trunk/src/web/javascript/ncbo-term-info.js 2006-11-02 16:13:23 UTC (rev 175) +++ phenote/trunk/src/web/javascript/ncbo-term-info.js 2006-11-02 17:45:28 UTC (rev 176) @@ -7,7 +7,7 @@ // this should be a relative link - need to get servlets code in/close with scripts? //var url = '/servlet/PhenoteStub'; //var url = '/servlet/Phenote'; // tomcat - not jboss -var url = '/phenote/Phenote'; // jboss +var url = '/phenote/Phenote/'; // jboss // getTermInfo should be called by the above url (at least for dichty it does) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-11-02 16:13:35
|
Revision: 175 http://svn.sourceforge.net/obo/?rev=175&view=rev Author: mgibson Date: 2006-11-02 08:13:23 -0800 (Thu, 02 Nov 2006) Log Message: ----------- took config out for check-for-new-ontologies intervalMinutes="5" as now replaced by quartz scheduler coming from christian Modified Paths: -------------- phenote/trunk/conf/initial-zfin.cfg phenote/trunk/conf/phenote-config.rnc phenote/trunk/jars/phenoteconfigbeans.jar phenote/trunk/src/java/phenote/config/Config.java Modified: phenote/trunk/conf/initial-zfin.cfg =================================================================== --- phenote/trunk/conf/initial-zfin.cfg 2006-11-02 00:21:23 UTC (rev 174) +++ phenote/trunk/conf/initial-zfin.cfg 2006-11-02 16:13:23 UTC (rev 175) @@ -2,8 +2,6 @@ <dataadapter name="phenosyntax"/> - <check-for-new-ontologies intervalMinutes="5"/> - <log config-file="conf/log4j.xml"/> <field name="Pub" /> Modified: phenote/trunk/conf/phenote-config.rnc =================================================================== --- phenote/trunk/conf/phenote-config.rnc 2006-11-02 00:21:23 UTC (rev 174) +++ phenote/trunk/conf/phenote-config.rnc 2006-11-02 16:13:23 UTC (rev 175) @@ -5,6 +5,7 @@ element phenote-configuration { attribute version { xsd:float }, check-for-new-ontologies, + ontology-archive, log, dataadapter*, field* @@ -17,10 +18,11 @@ } ## Whether to check if ontology(obo) has been updated/more current obo file -check-for-new-ontologies = - element check-for-new-ontologies { - attribute intervalMinutes { xsd:integer } - } +## I think this needs to be taken out as replaced by quartz scheduler +##check-for-new-ontologies = +## element check-for-new-ontologies { +## attribute intervalMinutes { xsd:integer } +## } ## Where the config file for log4j is log = Modified: phenote/trunk/jars/phenoteconfigbeans.jar =================================================================== (Binary files differ) Modified: phenote/trunk/src/java/phenote/config/Config.java =================================================================== --- phenote/trunk/src/java/phenote/config/Config.java 2006-11-02 00:21:23 UTC (rev 174) +++ phenote/trunk/src/java/phenote/config/Config.java 2006-11-02 16:13:23 UTC (rev 175) @@ -24,7 +24,7 @@ // in phenoteconfigbeans.jar code generate xml beans import phenote.config.xml.PhenoteConfigurationDocument; import phenote.config.xml.PhenoteConfigurationDocument.PhenoteConfiguration; -import phenote.config.xml.CheckForNewOntologiesDocument.CheckForNewOntologies; +//import phenote.config.xml.CheckForNewOntologiesDocument.CheckForNewOntologies; import phenote.config.xml.DataadapterDocument.Dataadapter; import phenote.config.xml.FieldDocument.Field; import phenote.config.xml.OntologyDocument.Ontology; @@ -52,8 +52,8 @@ //private FieldConfig geneticContextConfig; private List<DataAdapterI> dataAdapterList; private List<FieldConfig> fieldList = new ArrayList<FieldConfig>(); - private boolean checkForNewOntologies = false; - private int newOntologyCheckMinutes = 10; + //private boolean checkForNewOntologies = false; + //private int newOntologyCheckMinutes = 10; private String logConfigFile = "conf/log4j.xml"; // default log config file /** singleton */ @@ -155,13 +155,14 @@ return dataAdapterList.get(0); } - /** perhaps not best name - check if ontology is still fresh, if something newer - than load it - for obo files check file date - get this into config file! */ - public boolean checkForNewOntologies() { - return checkForNewOntologies; - } - /** How many minutes between checks for new ontologies */ - public int getOntologyCheckMinutes() { return newOntologyCheckMinutes; } + // --> quartz +// /** perhaps not best name - check if ontology is still fresh, if something newer +// than load it - for obo files check file date - get this into config file! */ +// public boolean checkForNewOntologies() { +// return checkForNewOntologies; +// } +// /** How many minutes between checks for new ontologies */ +// public int getOntologyCheckMinutes() { return newOntologyCheckMinutes; } public URL getLogConfigUrl() throws FileNotFoundException { return FileUtil.findUrl(logConfigFile); @@ -226,14 +227,14 @@ PhenoteConfiguration pc = pcd.getPhenoteConfiguration(); - // CHECK FOR ONTOLOGIES - CheckForNewOntologies cfno = pc.getCheckForNewOntologies(); - if (cfno != null) { // ? - checkForNewOntologies = true; - BigInteger bi = cfno.getIntervalMinutes(); - if (bi != null) - newOntologyCheckMinutes = bi.intValue(); - } +// // CHECK FOR ONTOLOGIES +// CheckForNewOntologies cfno = pc.getCheckForNewOntologies(); +// if (cfno != null) { // ? +// checkForNewOntologies = true; +// BigInteger bi = cfno.getIntervalMinutes(); +// if (bi != null) +// newOntologyCheckMinutes = bi.intValue(); +// } // LOG CONFIG FILE Log log = pc.getLog(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-11-02 00:21:25
|
Revision: 174 http://svn.sourceforge.net/obo/?rev=174&view=rev Author: mgibson Date: 2006-11-01 16:21:23 -0800 (Wed, 01 Nov 2006) Log Message: ----------- woops init ontologies was in wrong place Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-11-01 19:29:14 UTC (rev 173) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-11-02 00:21:23 UTC (rev 174) @@ -42,6 +42,7 @@ private OntologyDataAdapter() { config = Config.inst(); + initOntologies(); //if (config.checkForNewOntologies()){new OntologyFileCheckThread().start();} } @@ -51,7 +52,6 @@ public static synchronized OntologyDataAdapter getInstance() { if (singleton == null) singleton = new OntologyDataAdapter(); - singleton.initOntologies(); return singleton; } @@ -168,7 +168,6 @@ in place of old one */ public void reloadOntology(Ontology ont) throws OntologyException { loadOboSession(ont,ont.getSource()); // throws ex - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-11-01 19:29:29
|
Revision: 173 http://svn.sourceforge.net/obo/?rev=173&view=rev Author: mgibson Date: 2006-11-01 11:29:14 -0800 (Wed, 01 Nov 2006) Log Message: ----------- refactoring of ontology data adapter for quartz scheduler reloadOntologies renamed initOntologies which is called by getInstance - intiutive? need to call getInstance to load ontologies - perhaps funny 2 public methods getInstance for singleton & initialization reloadOntology() called by quartz scheduler if finds that file is out of synch (timestamp) now throw OntologyException if obo session fails to load - wraps DataAdapterException reloadOntology throws OntologyException if file not found or load fails Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/datamodel/OntologyException.java phenote/trunk/src/java/phenote/main/Phenote.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-10-31 21:56:27 UTC (rev 172) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-11-01 19:29:14 UTC (rev 173) @@ -22,6 +22,7 @@ import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; import phenote.datamodel.Ontology; +import phenote.datamodel.OntologyException; import phenote.datamodel.OntologyManager; import phenote.config.Config; import phenote.config.FieldConfig; @@ -36,24 +37,27 @@ private static OntologyDataAdapter singleton; private Config config; private OntologyManager ontologyManager = OntologyManager.inst(); - private boolean loadingOntologies = false; + private boolean initializingOntologies = false; private static final Logger LOG = Logger.getLogger(OntologyDataAdapter.class); private OntologyDataAdapter() { config = Config.inst(); - if (config.checkForNewOntologies()) { - new OntologyFileCheckThread().start(); - } + //if (config.checkForNewOntologies()){new OntologyFileCheckThread().start();} } - public static OntologyDataAdapter getInstance() { + /** synchronized so cant reload an ontology while ontologies are being initialized + getInstance calls initOntologies - in other words you have to call getInstance to + initialize the ontologies */ + public static synchronized OntologyDataAdapter getInstance() { if (singleton == null) singleton = new OntologyDataAdapter(); + singleton.initOntologies(); return singleton; } - public void loadOntologies() { - loadingOntologies = true; + private void initOntologies() { + // to prevent reload during init , maybe dont need with synchronization? + initializingOntologies = true; for (FieldConfig fieldConfig : config.getFieldConfigList()) { CharFieldEnum fce = fieldConfig.getCharFieldEnum(); CharField cf = new CharField(fce); @@ -62,11 +66,11 @@ if (fieldConfig.hasOntologies()) { for (OntologyConfig oc : fieldConfig.getOntologyConfigList()) { try { - Ontology o = loadOntology(oc); + Ontology o = initOntology(oc); cf.addOntology(o); - } catch (FileNotFoundException e) { + } catch (OntologyException e) { //System.out.println(e.getMessage()+" ignoring ontology, fix config! "); - LOG.error(e.getMessage()+" ignoring ontology, fix config! "); + LOG.error(e.getMessage()+" ignoring init ontology, fix config? "); } } } @@ -78,18 +82,18 @@ if (fieldConfig.isPostComp()) { cf.setPostCompAllowed(true); try { - //Ontology o = loadRelationshipOntology(fieldConfig.getPostCompRelOntCfg()); - Ontology o = loadOntology(fieldConfig.getPostCompRelOntCfg()); + //Ontology o = initRelationshipOntology(fieldConfig.getPostCompRelOntCfg()); + Ontology o = initOntology(fieldConfig.getPostCompRelOntCfg()); cf.setPostCompRelOntol(o); - } catch (FileNotFoundException e) { - LOG.error(e.getMessage()+" ignoring ontology, fix config! "); + } catch (OntologyException e) { + LOG.error(e.getMessage()+" ignoring ontology, fix config? "); } } ontologyManager.addField(cf); } - //loadRelationshipOntology(); + //initRelationshipOntology(); - loadingOntologies = false; + initializingOntologies = false; } @@ -97,7 +101,7 @@ /** Load up/cache Sets for all ontologies used, anatomyOntologyTermSet * and patoOntologyTermSet -- move to dataadapter/OntologyDataAdapter... */ - private Ontology loadOntology(OntologyConfig ontCfg) throws FileNotFoundException { + private Ontology initOntology(OntologyConfig ontCfg) throws OntologyException { Ontology ontology = new Ontology(ontCfg.name); if (ontCfg.hasFilter()) // set filter before loading obo session ontology.setFilter(ontCfg.getFilter()); @@ -113,10 +117,10 @@ // CharField cf = new CharField(relEnum); // } - private void loadOboSession(Ontology o,String filename) throws FileNotFoundException { - URL url = findFile(filename); // throws FileNotFoundEx + private void loadOboSession(Ontology o,String filename) throws OntologyException { + URL url = findFile(filename); // throws OntologyEx if file not found OBOSession oboSession = getOboSession(url); - o.setOboSession(oboSession); + o.setOboSession(oboSession); // throws OntEx if error File file = new File(url.getFile()); long date = file.lastModified(); //System.out.println(" file "+file+" mod "+date+" "+new Date(date)); @@ -128,15 +132,17 @@ - /** Look for file in current directory (.) and jar file */ - private URL findFile(String fileName) throws FileNotFoundException { - return FileUtil.findUrl(fileName); + /** Look for file in current directory (.) and jar file + throws OntologyException if file not found - wraps FileNFEx */ + private URL findFile(String fileName) throws OntologyException { + try { return FileUtil.findUrl(fileName); } + catch (FileNotFoundException e) { throw new OntologyException(e); } } // String -> url to handle web start jar obo files - private OBOSession getOboSession(URL oboUrl) { + private OBOSession getOboSession(URL oboUrl) throws OntologyException { if (oboUrl == null) return new OBOSessionImpl(); // ?? @@ -151,70 +157,79 @@ } catch (DataAdapterException e) { //System.out.println("got data adapter exception: "+e); - LOG.error("got data adapter exception: "+e); - return null; // empty session? + LOG.error("got data adapter exception: "+e); // ?? + //return null; // empty session? + throw new OntologyException(e); } } - private class OntologyFileCheckThread extends Thread { + /** The ontology has been determined to be out of date (by quartz) and thus directed + to reload itself from its file - in other words there is a new obo file to load + in place of old one */ + public void reloadOntology(Ontology ont) throws OntologyException { + loadOboSession(ont,ont.getSource()); // throws ex + + } - public void run() { +} - int checkMilliSecs = config.getOntologyCheckMinutes() * 60000; - //int checkMilliSecs = 6000;//0.6 * 60000; // debug - 10 secs - while(true) { - // sleep in milliseconds - try { sleep(checkMilliSecs); } - catch (InterruptedException e) { LOG.error("thread interrupted??"); } - // if still loading ontologies from previous run then dont bother - if (loadingOntologies) { - //System.out.println("Ontologies are being loaded - ontology checker going "+ - // "back to sleep"); - LOG.info("Ontologies are being loaded - ontology checker going "+ - "back to sleep"); - continue; - } - LOG.info("checking for new obo files..."); - //System.out.println("checking for new obo files..."); - // check for files... - synchOntologies(); - } - } - - /** Checks for new obo files */ - private void synchOntologies() { - for (CharField cf : ontologyManager.getCharFieldList()) { - for (Ontology o : cf.getOntologyList()) { - if (o.getSource() == null) continue; - String file = o.getSource(); - long oldTimestamp = o.getTimestamp(); - long newTimestamp = new File(file).lastModified(); - if (newTimestamp > oldTimestamp) { - Date d = new Date(newTimestamp); - //System.out.println("loading new obo file "+file+" new date "+d); - LOG.info("LOG loading new obo file "+file+" new date "+d); - try { - loadOboSession(o,file); - } catch (FileNotFoundException e) { // shouldnt happen - //System.out.println(e.getMessage()+" ignoring ontology, fix config! "); - LOG.error(e.getMessage()+" ignoring ontology, fix config! "); - // LOG.debug(stacktrace)??? no string for stack trace... hmm... - } - } - } - } - } - } -} +// GARBAGE + // refactor -> Quartz scheduler, reloadOntology() +// private class OntologyFileCheckThread extends Thread { +// public void run() { +// int checkMilliSecs = config.getOntologyCheckMinutes() * 60000; +// //int checkMilliSecs = 6000;//0.6 * 60000; // debug - 10 secs +// while(true) { +// // sleep in milliseconds +// try { sleep(checkMilliSecs); } +// catch (InterruptedException e) { LOG.error("thread interrupted??"); } -// GARBAGE -// // first try file as is (full path provided) +// // if still loading ontologies from previous run then dont bother +// if (initializingOntologies) { +// //System.out.println("Ontologies are being loaded - ontology checker going "+ +// // "back to sleep"); +// LOG.info("Ontologies are being initialized - ontology checker going "+ +// "back to sleep"); +// continue; +// } +// LOG.info("checking for new obo files..."); +// //System.out.println("checking for new obo files..."); +// // check for files... +// synchOntologies(); +// } +// } + +// /** Checks for new obo files */ +// private void synchOntologies() { +// for (CharField cf : ontologyManager.getCharFieldList()) { +// for (Ontology o : cf.getOntologyList()) { +// if (o.getSource() == null) continue; +// String file = o.getSource(); +// long oldTimestamp = o.getTimestamp(); +// long newTimestamp = new File(file).lastModified(); +// if (newTimestamp > oldTimestamp) { +// Date d = new Date(newTimestamp); +// //System.out.println("loading new obo file "+file+" new date "+d); +// LOG.info("LOG loading new obo file "+file+" new date "+d); +// try { +// loadOboSession(o,file); +// } catch (FileNotFoundException e) { // shouldnt happen +// //System.out.println(e.getMessage()+" ignoring ontology, fix config! "); +// LOG.error(e.getMessage()+" ignoring ontology, fix config! "); +// // LOG.debug(stacktrace)??? no string for stack trace... hmm... +// } +// } +// } +// } +// } + +/// // first try file as is (full path provided) // File file = new File(fileName); // if (file.exists()) // return makeUrl(fileName); Modified: phenote/trunk/src/java/phenote/datamodel/OntologyException.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyException.java 2006-10-31 21:56:27 UTC (rev 172) +++ phenote/trunk/src/java/phenote/datamodel/OntologyException.java 2006-11-01 19:29:14 UTC (rev 173) @@ -1,5 +1,9 @@ package phenote.datamodel; public class OntologyException extends Exception { + //private wrappedExce ? public OntologyException(String m) { super(m); } + public OntologyException(Exception e) { + this(e.getMessage()); + } } Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-31 21:56:27 UTC (rev 172) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-11-01 19:29:14 UTC (rev 173) @@ -32,7 +32,7 @@ public class Phenote { - private static final String VERSION = "0.8.1 dev"; + private static final String VERSION = "0.8.2 dev"; //private static final String DEFAULT_CONFIG_FILE = Config.DEFAULT_CONFIG_FILE; private static final Logger LOG = Logger.getLogger(Phenote.class); private static boolean standalone = false; // default for servlet @@ -81,7 +81,8 @@ public void initOntologies() { //OntologyDataAdapter oda = new OntologyDataAdapter(); // singleton? - OntologyDataAdapter.getInstance().loadOntologies(); // loads up OntologyManager + // loads up OntologyManager - non intuitive? + OntologyDataAdapter.getInstance(); } private void loadFromCommandLine() { Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-31 21:56:27 UTC (rev 172) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-11-01 19:29:14 UTC (rev 173) @@ -65,7 +65,8 @@ //String[] args = {"-c","initial-zfin.cfg"}; //phenote.initConfig(args); // hardwire for now to zfin //phenote.initOntologies(); - OntologyDataAdapter.getInstance().loadOntologies(); + // loads ontologies up - non intuitive? + OntologyDataAdapter.getInstance(); // this is not running as a separate thread - investigate // System.out.println("ontologies loaded - starting file checking thread"); // OntologyFileCheckThread ofct = new OntologyFileCheckThread(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-31 21:56:36
|
Revision: 172 http://svn.sourceforge.net/obo/?rev=172&view=rev Author: mgibson Date: 2006-10-31 13:56:27 -0800 (Tue, 31 Oct 2006) Log Message: ----------- ontology data adapter is now a singleton as it should be by christian request Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/main/Phenote.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-10-31 20:50:09 UTC (rev 171) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-10-31 21:56:27 UTC (rev 172) @@ -33,18 +33,25 @@ this is specifically a OboFileLoader - other kinds of ontology loading may com along*/ public class OntologyDataAdapter { + private static OntologyDataAdapter singleton; private Config config; private OntologyManager ontologyManager = OntologyManager.inst(); private boolean loadingOntologies = false; private static final Logger LOG = Logger.getLogger(OntologyDataAdapter.class); - public OntologyDataAdapter() { + private OntologyDataAdapter() { config = Config.inst(); if (config.checkForNewOntologies()) { new OntologyFileCheckThread().start(); } } + public static OntologyDataAdapter getInstance() { + if (singleton == null) + singleton = new OntologyDataAdapter(); + return singleton; + } + public void loadOntologies() { loadingOntologies = true; for (FieldConfig fieldConfig : config.getFieldConfigList()) { Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-31 20:50:09 UTC (rev 171) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-31 21:56:27 UTC (rev 172) @@ -80,8 +80,8 @@ // } public void initOntologies() { - OntologyDataAdapter oda = new OntologyDataAdapter(); // singleton? - oda.loadOntologies(); // loads up OntologyManager + //OntologyDataAdapter oda = new OntologyDataAdapter(); // singleton? + OntologyDataAdapter.getInstance().loadOntologies(); // loads up OntologyManager } private void loadFromCommandLine() { Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-31 20:50:09 UTC (rev 171) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-31 21:56:27 UTC (rev 172) @@ -25,6 +25,7 @@ import phenote.config.Config; import phenote.config.ConfigException; import phenote.main.Phenote; +import phenote.dataadapter.OntologyDataAdapter; public class PhenoteServlet extends HttpServlet { @@ -34,7 +35,7 @@ //private String configurationFileName; not sure needs to be var private Date initDate; - private Phenote phenote; + //private Phenote phenote; /** * if <load-on-startup>1</load-on-startup> is in web.xml then init will @@ -46,7 +47,7 @@ super.init(); // makes links for term info - put this method in Phenote? HtmlUtil.setStandAlone(false); - phenote = Phenote.getPhenote(); + //phenote = Phenote.getPhenote(); // from web.xml String configFile = getInitParameter(CONFIG_FILE_PARAM); // just in case not in web.xml @@ -63,7 +64,8 @@ // cheesy - revisit //String[] args = {"-c","initial-zfin.cfg"}; //phenote.initConfig(args); // hardwire for now to zfin - phenote.initOntologies(); + //phenote.initOntologies(); + OntologyDataAdapter.getInstance().loadOntologies(); // this is not running as a separate thread - investigate // System.out.println("ontologies loaded - starting file checking thread"); // OntologyFileCheckThread ofct = new OntologyFileCheckThread(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-31 20:50:24
|
Revision: 171 http://svn.sourceforge.net/obo/?rev=171&view=rev Author: mgibson Date: 2006-10-31 12:50:09 -0800 (Tue, 31 Oct 2006) Log Message: ----------- web dev docs some work with getting syns in auto comp list in servlet/web not yet displaying term on selecting syn - getting there... may need to fiddle with ajax classes as shu has done Modified Paths: -------------- phenote/trunk/doc/developer-docs phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java phenote/trunk/src/web/html/ncbo.html Added Paths: ----------- phenote/trunk/doc/web-developer-docs Modified: phenote/trunk/doc/developer-docs =================================================================== --- phenote/trunk/doc/developer-docs 2006-10-31 15:53:08 UTC (rev 170) +++ phenote/trunk/doc/developer-docs 2006-10-31 20:50:09 UTC (rev 171) @@ -38,3 +38,13 @@ So if a field only has one ontology you can shove that file in the field element as an attribute. For multiple ontologies you need to add ontology elements. Once the gui configuration is in place no one will need to know about this (unless one prefers mucking with xml over guis). + + + +> Is it correct that you keep the file information from which an ontology +> was loaded? + +yes - phenote keeps the file name (source) and timestamp (as long) in +phenote.datamodel.Ontology +phenote.datamodel.OntologyManager has a list of +phenote.datamodel.CharFields which have a list of Ontologys Added: phenote/trunk/doc/web-developer-docs =================================================================== --- phenote/trunk/doc/web-developer-docs (rev 0) +++ phenote/trunk/doc/web-developer-docs 2006-10-31 20:50:09 UTC (rev 171) @@ -0,0 +1,150 @@ +heres how PhenoteServlet makes the auto completion response: + + private String getCompletionList(String userInput,String ontol,String field) { + StringBuffer sb = new StringBuffer("<ul>"); + try { + Vector<CompletionTerm> v = +getCompListSearcher(ontol).getStringMatchTerms(userInput); + //Vector<OBOClass> v = ontology.getStringMatchTerms(userInput, +getSearchParams()); + for (CompletionTerm ct : v) + sb.append(makeCompListHtmlItem(ct, ontol, field)); + } + catch (OntologyException e) { sb.append(e.getMessage()); } + sb.append("</ul>"); + return sb.toString(); + } + private String makeCompListHtmlItem(CompletionTerm term, String ontol,String +field) { + String id = term.getID(), name=term.getName(); + String display = term.getCompListDisplayString(); + // pass in id, name & ontology - name for setting field on UseTerm + StringBuffer info = dq(fn("getTermInfo",new String[]{id,name,ontol,field})); + StringBuffer select = dq(fn("selectTerm",new String[]{name,field})); + //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; + return "<li onmouseover=" + info + " id=" + q(id) + " " + + "onclick=" + select + ">" + display + "</li>\n"; + } + + private static StringBuffer fn(String fnName, String[] params) { + return HtmlUtil.fn(fnName,params); + } + + +so basically the ajax autocompleter expects a <ul> list - not a page, not a +single string. furthermore the <li> elements of the list have onMouseOver +getTermInfo javascript functions wired into them. Im working on a selectTerm +fuction on mouse click to get term names to show up on synonym select but that +isnt working yet. So the response needs to look like this: + +<ul> + <li onmouseover=getTermInfo('id','name','ontol','field') id='id' + onclick=selectTerm('name','field') > termName </li> + <li ... +</ul> + + +src/web documentation of js,html,ajax...: + +This is a web widget to search ontologies dynamically using Ajax. The +following describes the various compoents of the widget and how to use it. + +Style sheet: /css/control.js +This contains all the styles used in the widget + +Javascript: +/javascript/dichty-term-info.js contains a method to call Ajax to +update the Ontology information in the term info panel. +In this javascript the "var url" should point to the processing script. + +/javascript/ajax-lib contains Ajax libraries from Prototype +for ajax and its auto completer +http://prototype.conio.net/ + +Perl +/perl contains an example of a Ajax request processing script. +It is written in CGI perl. + + +------------------- +src/web/html Files: +------------------- +dichty.html interface.html ncbo.html term_completer.html + +dichty.html: I think this is old and should be deleted - sohel? replaced by interface.html + + +interface.html: +--------------- +This should be renamed dichty-top.html as this is dichty base's new +top level html page. The improvement over dichty.html (amongst other additions) is +that it generically creates fields using the Sever Side Includes(SSI) file +term_completer.html. Also has commit & retrieve buttons, that call javascript functions. + +term_completer.html +------------------- +This is generic server side include stuff for interface.html. It takes vars tag, title, + & url. see interface.html for use. This should be renamed term_completion_field.ssi + or just field.ssi (are all fields term completion - some may be free text) or + field_template.ssi? + + +ncbo.html +--------- +This is the top html page for ncbo/zfin (rename zfin.html?). It should use the new +SSI paradigm and use the term_completer.html SSI stuff. But this does have stuff that +interface/term_completer lacks. That is it has an entity chooser (dichtybase has no +need for one), and a UseTerm button. These require both an ontology name and field +name to be passed into the auto completion function. Also method names are renamed +for clarity sake. + + +So in summary ncbo.html & interface.html need to grab stuff from each other. Both of which +serve as templates for new groups coming up with there own top level page (mod.html) + + + +-------------------------- +src/web/javascript readme +-------------------------- +3 files: dichty-term-info.js ncbo-term-info.js term-completer.js +one sub directory: ajax-lib + +ajax-lib is open source ajax code from scriptaculous that the above files use. +in theory these shouldnt need to be modified (though ive had my temptations) + +The 3 scripts are all for term info retrieval from the backend. They should +probably be merged & deleted. The main variant is the backend url to get term info +from and that url should come from the top page where all mod specific stuff is set, +rather than here. Once that is done should be able to merge. + +These scripts are called with onMouseOver that is in the completion list that is +returned by the backend server(be it perl servlet or whatnot) for autocompletion. + +dichty-term-info.js might be old and if so should be deleted? sohel? + +term_completer.js is the new dichty base script (or old??) should be merged +with ncbo-term-info.js. Sohel that would require you to change your mouseOver +function call from the completion list to getTermInfo - would that be ok? + +ncbo-term-info.js +----------------- +is used for zfin/ncbo. There are some difference to dichty here. +The method is called getTermInfo which is a clearer name then set_ontology or +set_ontology_term. The url is different and as said above should be set in +the top mod specific page not here. + +OntologyName & field are passed as +parameters. Ontology name is needed for cases where theres an ontology chooser +(zfin entity - dichty can ignore this). field is needed so the Use Term button +of TermInfo knows which field to update (its the field the original term came from). + +In the top level html (ncbo.html) the form with the terms is given the name +termForm and that is used instead of forms[0] which can be presumptious if plugging +into a mods web page. + +The checking of the length of the ontologyid array was scrapped as it was unnecasary. + +So these scripts should be merged, and I think the ncbo changes should be incorporated. +Would you agree sohel? + Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-10-31 15:53:08 UTC (rev 170) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-10-31 20:50:09 UTC (rev 171) @@ -126,46 +126,8 @@ return FileUtil.findUrl(fileName); } -// // first try file as is (full path provided) -// File file = new File(fileName); -// if (file.exists()) -// return makeUrl(fileName); -// String oboFileDir = "obo-files/"; -// // try current directory + obo-file dir -// String currentDir = "./" + oboFileDir + fileName; -// file = new File(currentDir); -// if (file.exists()) -// return makeUrl(currentDir); -// // try jar - hopefully this works... jar files have to have '/' prepended -// // first try without obo-files dir (in jar) -// String jarFile = "/" + fileName; -// URL url = Ontology.class.getResource(jarFile); // looks in jar -// // 2nd try with obo-files dir in jar file (i used to do it this way) -// if (url == null) { -// jarFile = "/" + oboFileDir + fileName; -// url = Ontology.class.getResource(jarFile); // looks in jar -// } - -// if (url == null) { -// throw new FileNotFoundException("No file found for "+fileName); -// } -// return url; -// } - -// private URL makeUrl(String file) { -// try { -// return new URL("file:"+file); -// } -// catch (MalformedURLException e) { -// //System.out.println("malformed url "+file+" "+e); -// LOG.error("malformed url "+file+" "+e); -// return null; -// } -// } - - // String -> url to handle web start jar obo files private OBOSession getOboSession(URL oboUrl) { if (oboUrl == null) @@ -245,6 +207,44 @@ // GARBAGE +// // first try file as is (full path provided) +// File file = new File(fileName); +// if (file.exists()) +// return makeUrl(fileName); + +// String oboFileDir = "obo-files/"; +// // try current directory + obo-file dir +// String currentDir = "./" + oboFileDir + fileName; +// file = new File(currentDir); +// if (file.exists()) +// return makeUrl(currentDir); + +// // try jar - hopefully this works... jar files have to have '/' prepended +// // first try without obo-files dir (in jar) +// String jarFile = "/" + fileName; +// URL url = Ontology.class.getResource(jarFile); // looks in jar +// // 2nd try with obo-files dir in jar file (i used to do it this way) +// if (url == null) { +// jarFile = "/" + oboFileDir + fileName; +// url = Ontology.class.getResource(jarFile); // looks in jar +// } + +// if (url == null) { +// throw new FileNotFoundException("No file found for "+fileName); +// } +// return url; +// } + +// private URL makeUrl(String file) { +// try { +// return new URL("file:"+file); +// } +// catch (MalformedURLException e) { +// //System.out.println("malformed url "+file+" "+e); +// LOG.error("malformed url "+file+" "+e); +// return null; +// } +// } // if (date > 0) { // jar files have 0 date??? // ontology.setTimestamp(date); // ontology.setSource(file.toString()); Modified: phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-31 15:53:08 UTC (rev 170) +++ phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-31 20:50:09 UTC (rev 171) @@ -31,10 +31,10 @@ boolean isStartsWithMatch() { return startsWith; } public String toString() { - return compListDisplayString(); + return getCompListDisplayString(); } - private String compListDisplayString() { + public String getCompListDisplayString() { StringBuffer display = new StringBuffer(); StringBuffer appends = new StringBuffer(); if (isSynMatch()) { Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-31 15:53:08 UTC (rev 170) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-31 20:50:09 UTC (rev 171) @@ -75,7 +75,12 @@ /** * AUTO COMPLETE REQUEST * this should be done in java server faces/pages(?), post comes from ajax - * autocompleter on typing in stuff + * autocompleter on typing in stuff. prints html ul list to response: + <ul> + <li onmouseover=getTermInfo('id','name','ontol','field') id='id' + onclick=selectTerm('name','field') > termName </li> + <li ... + </ul> */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { @@ -220,11 +225,13 @@ private String makeCompListHtmlItem(CompletionTerm term, String ontol,String field) { String id = term.getID(), name=term.getName(); + String display = term.getCompListDisplayString(); // pass in id, name & ontology - name for setting field on UseTerm StringBuffer info = dq(fn("getTermInfo",new String[]{id,name,ontol,field})); + StringBuffer select = dq(fn("selectTerm",new String[]{name,field})); //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; return "<li onmouseover=" + info + " id=" + q(id) + " " + - "onclick=" + info + ">" + name + "</li>\n"; + "onclick=" + select + ">" + display + "</li>\n"; } private static StringBuffer fn(String fnName, String[] params) { @@ -254,25 +261,25 @@ } private class HardWiredSearchParams implements SearchParamsI { - public boolean searchTerms() { - return true; - } - - public boolean searchSynonyms() { - return false; // --> true - } - - public boolean searchDefinitions() { - return false; // ?? w [def]?? - } - - /** - * Whether to include obsoletes in searching terms, syns, & definitions - * This should be in conjunction with the other 3 - */ - public boolean searchObsoletes() { - return false; // --> true w [obs], disallow selection - } + public boolean searchTerms() { + return true; + } + + public boolean searchSynonyms() { + return true; // --> true + } + + public boolean searchDefinitions() { + return false; // ?? w [def]?? + } + + /** + * Whether to include obsoletes in searching terms, syns, & definitions + * This should be in conjunction with the other 3 + */ + public boolean searchObsoletes() { + return false; // --> true w [obs], disallow selection + } } } Modified: phenote/trunk/src/web/html/ncbo.html =================================================================== --- phenote/trunk/src/web/html/ncbo.html 2006-10-31 15:53:08 UTC (rev 170) +++ phenote/trunk/src/web/html/ncbo.html 2006-10-31 20:50:09 UTC (rev 171) @@ -165,8 +165,23 @@ } </script> + <script type="text/javascript"> + function selectTerm(termName) { + var field = document.termForm.activeField.value; + //var termName = document.termForm.termInfoTermName.value; + //alert('use term info fn called - field '+field+' name '+termName); + <!-- document.termForm.qualityInput.value=document.termForm.termId.value; --> + if (field == "ENTITY") { + document.termForm.entityInput.value = termName; + } + else { + document.termForm.qualityInput.value= termName; + } + } + </script> + <!-- /td --> <!-- /tr --> <!-- tr height="80%" --><!-- td --> <!-- /td --></tr --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-31 15:53:13
|
Revision: 170 http://svn.sourceforge.net/obo/?rev=170&view=rev Author: mgibson Date: 2006-10-31 07:53:08 -0800 (Tue, 31 Oct 2006) Log Message: ----------- not sure if this is the right place for it but ive added docs about configuration to the new developer-docs file. Added Paths: ----------- phenote/trunk/doc/developer-docs Added: phenote/trunk/doc/developer-docs =================================================================== --- phenote/trunk/doc/developer-docs (rev 0) +++ phenote/trunk/doc/developer-docs 2006-10-31 15:53:08 UTC (rev 170) @@ -0,0 +1,40 @@ +CONFIGURATION +------------- + +> do you have docs on how to configure it (eg, +> how to change the ontologies that are available to phenote). + +no there isnt yet docs on configuring - at the moment the only way to configure is to modify the xml config file, but on the todo (medium priority) is to have a gui for configuration as biomed users will not want to deal with an xml file. + +If you want to change the configuration via xml you will need to run from svn (for now, with webstart you would have to modify the conf file in the jar which im sure you dont want to get into). When you run phenote for the first time you can specify a config file at the command line with something like -c initial_zfin.cfg, which will copy conf/initial_zfin.cfg into ~/.phenote/my-phenote.cfg (if no -c specified & no my-phenote.cfg in place then conf/initial-flybase.cfg is copied by default). + +You can then modify the contents of ~/.phenote/my-phenote.cfg. Alternatively you can make your own config file and load it up with -c. In any case the xml file looks like this: + +<phenote-configuration version="0.8" xmlns="phenote/config/xml"> + + <dataadapter name="phenosyntax"/> + + <log config-file="conf/log4j-standalone.xml" /> + + <field name="Pub" /> + + <field name="Genotype" type="free_text"/> + + <field name="Genetic Context" file="context.obo"/> + + <field name="Entity"> + <postcomp relationship-ontology="relationship.obo"/> + <ontology name="Fly" file="fly_anatomy.obo" /> + <ontology name="GO" file="gene_ontology.obo"/> + <ontology name="SP" file="spatial.obo"/> + </field> + + <field name="Quality" file="quality.obo"/> + + +</phenote-configuration> + + +So if a field only has one ontology you can shove that file in the field element as an attribute. For multiple ontologies you need to add ontology elements. + +Once the gui configuration is in place no one will need to know about this (unless one prefers mucking with xml over guis). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-31 15:46:04
|
Revision: 169 http://svn.sourceforge.net/obo/?rev=169&view=rev Author: mgibson Date: 2006-10-31 07:46:00 -0800 (Tue, 31 Oct 2006) Log Message: ----------- cfg version 0.7 -> 0.8 Modified Paths: -------------- phenote/trunk/conf/initial-flybase.cfg Modified: phenote/trunk/conf/initial-flybase.cfg =================================================================== --- phenote/trunk/conf/initial-flybase.cfg 2006-10-31 15:17:32 UTC (rev 168) +++ phenote/trunk/conf/initial-flybase.cfg 2006-10-31 15:46:00 UTC (rev 169) @@ -1,5 +1,5 @@ -<phenote-configuration version="0.7" xmlns="phenote/config/xml"> +<phenote-configuration version="0.8" xmlns="phenote/config/xml"> <dataadapter name="phenosyntax"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-31 15:17:38
|
Revision: 168 http://svn.sourceforge.net/obo/?rev=168&view=rev Author: mgibson Date: 2006-10-31 07:17:32 -0800 (Tue, 31 Oct 2006) Log Message: ----------- release 0.8 - post comp, syn comp hits... Added Paths: ----------- phenote/tags/release-0.8/ Copied: phenote/tags/release-0.8 (from rev 167, phenote/trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-10-25 17:29:44
|
Revision: 167 http://svn.sourceforge.net/obo/?rev=167&view=rev Author: balhoff Date: 2006-10-25 10:29:35 -0700 (Wed, 25 Oct 2006) Log Message: ----------- Changed SearchParamPanel to use checkboxes instead of radio buttons, since the search choices are not mutually exclusive. This fulfills request 1579365. Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java Modified: phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java 2006-10-25 16:55:41 UTC (rev 166) +++ phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java 2006-10-25 17:29:35 UTC (rev 167) @@ -6,17 +6,17 @@ import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JRadioButton; +import javax.swing.JCheckBox; //import phenote.datamodel.SearchParamsI; // only public for TestPhenote public class SearchParamPanel { private SearchParamsI searchParams; - private JRadioButton termButton; - private JRadioButton synonymButton; - private JRadioButton definitionButton; - private JRadioButton obsoleteButton; + private JCheckBox termButton; + private JCheckBox synonymButton; + private JCheckBox definitionButton; + private JCheckBox obsoleteButton; // SearchParamPanel() { // CompletionList.setSearchParams(new SearchParams()) } @@ -40,8 +40,8 @@ return panel; } - private JRadioButton makeButton(String label) { - JRadioButton button = new JRadioButton(label); + private JCheckBox makeButton(String label) { + JCheckBox button = new JCheckBox(label); return button; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-10-25 16:55:45
|
Revision: 166 http://svn.sourceforge.net/obo/?rev=166&view=rev Author: balhoff Date: 2006-10-25 09:55:41 -0700 (Wed, 25 Oct 2006) Log Message: ----------- Modified phenosyntax and phenoxml data adapters to use save dialog when saving (instead of open dialog). File choosing should probably be moved out of the PhenoXmlAdapter class, but I haven't done this. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxFileAdapter.java phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxFileAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxFileAdapter.java 2006-10-19 13:06:15 UTC (rev 165) +++ phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxFileAdapter.java 2006-10-25 16:55:41 UTC (rev 166) @@ -35,7 +35,7 @@ public void load() { if (file == null) - file = getFileFromUser(previousFile); + file = getFileFromUserForOpen(previousFile); if (file == null) return; previousFile = file; @@ -62,14 +62,22 @@ } /** returns null if user fails to pick a file */ - private File getFileFromUser(File dir) { - return PhenoXmlAdapter.getFileFromUser(dir); // perhaps a util class + // private File getFileFromUser(File dir) { + // return PhenoXmlAdapter.getFileFromUser(dir); // perhaps a util class + // } + + private File getFileFromUserForSave(File dir) { + return PhenoXmlAdapter.getFileFromUserForSave(dir); } + + private File getFileFromUserForOpen(File dir) { + return PhenoXmlAdapter.getFileFromUserForOpen(dir); + } public void commit(CharacterListI charList) { if (file == null) - file = getFileFromUser(previousFile); + file = getFileFromUserForSave(previousFile); if (file == null) return; previousFile = file; Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-10-19 13:06:15 UTC (rev 165) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-10-25 16:55:41 UTC (rev 166) @@ -48,7 +48,7 @@ public void load() { try { if (file == null) { - file = getFileFromUser(previousFile); + file = getFileFromUserForOpen(previousFile); } if (file == null) return; previousFile = file; @@ -159,7 +159,7 @@ public void commit(CharacterListI charList) { if (file == null) - file = getFileFromUser(previousFile); + file = getFileFromUserForSave(previousFile); if (file == null) return; previousFile = file; @@ -183,18 +183,31 @@ } } - public static File getFileFromUser(File dir) { + public static File getFileFromUserIsSave(File dir, boolean isSave) { // todo - remember last accessed dir JFileChooser fileChooser = new JFileChooser(dir); // todo - file filter - only .xml or .phenoxml? - int returnVal = fileChooser.showOpenDialog(null); - if(returnVal == JFileChooser.APPROVE_OPTION) + int returnVal; + if (isSave) { + returnVal = fileChooser.showSaveDialog(null); + } else { + returnVal = fileChooser.showOpenDialog(null); + } + if (returnVal == JFileChooser.APPROVE_OPTION) return fileChooser.getSelectedFile(); else { System.out.println("no file chosen"); return null; } } + + public static File getFileFromUserForSave(File dir) { + return getFileFromUserIsSave(dir, true); + } + + public static File getFileFromUserForOpen(File dir) { + return getFileFromUserIsSave(dir, false); + } private XmlOptions getXmlOptions() { XmlOptions options = new XmlOptions(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-18 20:40:33
|
Revision: 164 http://svn.sourceforge.net/obo/?rev=164&view=rev Author: mgibson Date: 2006-10-18 13:40:22 -0700 (Wed, 18 Oct 2006) Log Message: ----------- uml class diagram done in macs graffle and exported to pdf Added Paths: ----------- phenote/trunk/doc/phenote-uml-graffle.pdf Added: phenote/trunk/doc/phenote-uml-graffle.pdf =================================================================== (Binary files differ) Property changes on: phenote/trunk/doc/phenote-uml-graffle.pdf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-18 17:39:28
|
Revision: 163 http://svn.sourceforge.net/obo/?rev=163&view=rev Author: mgibson Date: 2006-10-18 10:39:21 -0700 (Wed, 18 Oct 2006) Log Message: ----------- fixed bug where if you type a letter then click another field or hit new then type same letter in same field ya get no comp list this was due to inputChanged() check that seems like a good check but actually isnt useful and ctually harmful - so i just took it out Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-18 16:18:25 UTC (rev 162) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-18 17:39:21 UTC (rev 163) @@ -279,8 +279,12 @@ // through, taking out keyTyped, inputChanged may be sufficient // if (!keyTyped) // if user hasnt typed anything dont bother // return; - if (!inputChanged()) // if input is actually same no need to recomp - return; + //log().debug("inputchanged "+inputChanged()); + // this seems like a good idea but leads to a bug - if user types a letter + // then hits "New" then comes back and types same letter then this stops comp + // also i dont think this actually stops any funny behavior + //if (!inputChanged()) // if input is actually same no need to recomp + //return; keyTyped = false; // too soon - text field doesnt have text yet.... hmmmm.... String input = getText(); @@ -318,14 +322,14 @@ } - /** returns true if input changed from previously recorded input */ - private boolean inputChanged() { - String newInput = getText(); - boolean inputChanged = ! previousInput.equals(newInput); - if (inputChanged) - previousInput = newInput; - return inputChanged; - } +// /** returns true if input changed from previously recorded input */ +// private boolean inputChanged() { +// String newInput = getText(); +// boolean inputChanged = ! previousInput.equals(newInput); +// if (inputChanged) +// previousInput = newInput; +// return inputChanged; +// } /** call Ontology to get a Vector of OBOClass's that contain "in" in ontology */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-18 16:18:28
|
Revision: 162 http://svn.sourceforge.net/obo/?rev=162&view=rev Author: mgibson Date: 2006-10-18 09:18:25 -0700 (Wed, 18 Oct 2006) Log Message: ----------- fixed bug where post comp gui commit wasnt showing up in entity text field. problem was was doing a setText for char changes - but now comp lists need to synch with model and get current obo class. - so now synchs with model thats changed instead of getting text from event. Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java Modified: phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java 2006-10-18 14:05:43 UTC (rev 161) +++ phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java 2006-10-18 16:18:25 UTC (rev 162) @@ -93,15 +93,16 @@ EditManager.inst().addCharChangeListener(new FieldCharChangeListener()); } - // i think this was to receive edits from term info?? which no longer edits - - // but could imagine other things editing?? investigate this + /** edits from post comp come in here i believe (term info used to but now + thats done with UseTermEvent */ private class FieldCharChangeListener implements CharChangeListener { public void charChanged(CharChangeEvent e) { // check charField is this char field if (e.getSource() != CharFieldGui.this && e.isForCharField(charField)) // i think all we need to do is setText to synch with model // for complist dont we also need to set its model (not just text??) - setText(e.getValueString()); + //setText(e.getValueString()); // might as well just synch with model + setValueFromChar(getSelectedChar()); } } @@ -289,6 +290,10 @@ CharFieldEnum getCharFieldEnum() { return charField.getCharFieldEnum(); } + private CharacterI getSelectedChar() { + return SelectionManager.inst().getSelectedCharacter(); + } + // separate char text field class? /** This is where the model gets updated (for free text fields) */ private class TextFieldDocumentListener implements DocumentListener { @@ -301,7 +306,7 @@ //if (!characterTablePanel.hasRows()) return; //String genotype = lumpField.getText(); //characterTablePanel.setSelectedGenotype(genotype); - CharacterI c = SelectionManager.inst().getSelectedCharacter(); + CharacterI c = getSelectedChar(); // i believe this isnt using oboClass as we just have string // of course it isnt this is free text String v = getText(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-18 14:05:51
|
Revision: 161 http://svn.sourceforge.net/obo/?rev=161&view=rev Author: mgibson Date: 2006-10-18 07:05:43 -0700 (Wed, 18 Oct 2006) Log Message: ----------- fixed bug where fields werent resetting on character selection in table on char selection comp list wasnt setting its (new) model as comp list now tracks model this has side effect that invalid text (non-term) is getting wiped out if go on to new field - this is something nicole requested so keep it for now - maybe its better that way but i noticed a new bug sometimes comp list not coming in on 1st char - but sometimes it is Modified Paths: -------------- phenote/trunk/src/java/phenote/config/OntologyConfig.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java phenote/trunk/src/java/phenote/gui/field/RelationCompList.java phenote/trunk/src/java/phenote/gui/field/TermCompList.java Modified: phenote/trunk/src/java/phenote/config/OntologyConfig.java =================================================================== --- phenote/trunk/src/java/phenote/config/OntologyConfig.java 2006-10-17 13:09:04 UTC (rev 160) +++ phenote/trunk/src/java/phenote/config/OntologyConfig.java 2006-10-18 14:05:43 UTC (rev 161) @@ -5,11 +5,11 @@ public String name; public String ontologyFile; - public String nameSpace; + //public String nameSpace; // not used yet - or was this what filter out ended up public String filterOut; // public typeEnum? type?? eg Entity/GT/Pato...?? - static OntologyConfig defaultPato = new OntologyConfig("Pato","attribute_and_value.obo"); + //static OntologyConfig defaultPato = new OntologyConfig("Pato","attribute_and_value.obo"); OntologyConfig() {} // not sure this is actually needed/used OntologyConfig(String name) { this.name = name; } Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-10-17 13:09:04 UTC (rev 160) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-10-18 14:05:43 UTC (rev 161) @@ -80,7 +80,7 @@ merge this with getOboClassWithEx? */ public OBOClass getOboClass(String id) throws TermNotFoundException { OBOClass oboClass; -// this seems to be the sole reason for ontology list - silly! +// this seems to be the sole reason for ontology list - silly! use char fields! Iterator<Ontology> iter = allOntologyList.iterator(); while (iter.hasNext()) { Ontology o = iter.next(); Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-17 13:09:04 UTC (rev 160) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-18 14:05:43 UTC (rev 161) @@ -28,6 +28,7 @@ import org.geneontology.oboedit.datamodel.OBOProperty; import phenote.datamodel.CharField; +import phenote.datamodel.CharacterI; //import phenote.datamodel.CharFieldEnum; //import phenote.datamodel.CharacterI; //import phenote.datamodel.Ontology; @@ -110,6 +111,12 @@ protected boolean editModelEnabled() { return editModel; } + /** char in table changed - adjust - not needed for rel(at least not yet) + as post comp doesnt listen to table changes (does it? should it?), + just term */ + protected abstract void setValueFromChar(CharacterI chr); + // {charField.getCharFieldEnum().getValue(chr).getOboClass() } + ///** If true than the auto combo is for setting the differentia in a post comp term, // if false (default) than no post comp or genus in post comp */ //void setIsDifferentia(boolean isDiff) { isDifferentia = isDiff; } @@ -126,7 +133,7 @@ this.doCompletion = doCompletion; this.keyTyped = doCompletion; // key has to be typed for completion getEditor().setItem(text); - //log().debug("setting text "+text); + //if (charField!=null)log().debug(charField.getName()+" setting text ["+text+"]"); //new Throwable().printStackTrace(); this.doCompletion = true; // set back to default } @@ -198,7 +205,8 @@ // but this is needed from mouse release on selection set text // is called and will cause completion list to come up after sel // w/o it - //log().debug("AutoTextField.setText "+text); + //if (charField!=null) + //log().debug(charField.getName()+" AutoTextField.setText ["+text+"]"+getCurrentTermRelName()); //new Throwable().printStackTrace(); doCompletion = false; //this is problematic for syns & such where string is diff than term name @@ -441,7 +449,7 @@ //log().debug("configure editor called"+anItem); //new Throwable().printStackTrace(); // it appears to be ok to supress this entirely - // super.configureEditor(anEditor,anItem); // ??? supress + super.configureEditor(anEditor,anItem); // ??? supress } Modified: phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java 2006-10-17 13:09:04 UTC (rev 160) +++ phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java 2006-10-18 14:05:43 UTC (rev 161) @@ -93,11 +93,14 @@ EditManager.inst().addCharChangeListener(new FieldCharChangeListener()); } + // i think this was to receive edits from term info?? which no longer edits - + // but could imagine other things editing?? investigate this private class FieldCharChangeListener implements CharChangeListener { public void charChanged(CharChangeEvent e) { // check charField is this char field if (e.getSource() != CharFieldGui.this && e.isForCharField(charField)) // i think all we need to do is setText to synch with model + // for complist dont we also need to set its model (not just text??) setText(e.getValueString()); } } @@ -147,6 +150,9 @@ +" names in config "); return; } + // if its a comp list need to set its model/current term rel (for AACL.setText) + if (isCompList) + getCompList().setValueFromChar(character); String v = charField.getCharFieldEnum().getValue(character).getName(); setText(v); } Modified: phenote/trunk/src/java/phenote/gui/field/RelationCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2006-10-17 13:09:04 UTC (rev 160) +++ phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2006-10-18 14:05:43 UTC (rev 161) @@ -6,6 +6,9 @@ import org.geneontology.oboedit.datamodel.OBOProperty; +import phenote.datamodel.CharacterI; + + class RelationCompList extends AbstractAutoCompList { private OBOProperty currentRel=null; @@ -89,6 +92,11 @@ /** no-op - relation list doesnt edit model (at least presently) */ protected void editModel() {} + /** char in table changed - adjust - not needed for rel(at least not yet) + as post comp doesnt listen to table changes (does it? should it?), + just term */ + protected void setValueFromChar(CharacterI chr) {} + /** Returns a vector of CompletionRelations for auto completion which contain input, using search params */ protected Vector getSearchItems(String input) { Modified: phenote/trunk/src/java/phenote/gui/field/TermCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2006-10-17 13:09:04 UTC (rev 160) +++ phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2006-10-18 14:05:43 UTC (rev 161) @@ -27,6 +27,20 @@ } + /** char in table changed - setCurrentOboClass & text */ + protected void setValueFromChar(CharacterI chr) { + OBOClass selCharTerm = + getCharField().getCharFieldEnum().getValue(chr).getOboClass(); + // if null then user has made a new char or selected a char with no term + if (selCharTerm == null) { + currentOboClass = null; // makes getCurTermRelName "" + setText(""); // actually calls getCurTermRelNm which is "" + } + else { + setOboClass(selCharTerm); // doesnt allow null + } + } + protected Vector getSearchItems(String input) { return getCompListSearcher().getStringMatchTerms(input); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-17 13:09:12
|
Revision: 160 http://svn.sourceforge.net/obo/?rev=160&view=rev Author: mgibson Date: 2006-10-17 06:09:04 -0700 (Tue, 17 Oct 2006) Log Message: ----------- fixed the bug where layout was going to hell when there was long terms in the completion list. the big fix wierdly enough was that a minimum size needed to be set for the comp list combo box - java layout is so wierd - anyways also using a mono space which may be controversial i dont know its not the prettiest of fonts - hopefully its a cross platform font i assume it is - and also cutting off long terms with ... Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java phenote/trunk/src/java/phenote/main/Phenote.java Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-16 16:03:41 UTC (rev 159) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-17 13:09:04 UTC (rev 160) @@ -71,13 +71,22 @@ // this will probably throw errors if non metal look & feel is used setUI(new MetalListComboUI()); setEditable(true); - setPreferredSize(new Dimension(350,22)); - setMaximumSize(new Dimension(350,22)); + setPreferredSize(new Dimension(390,22)); + setMaximumSize(new Dimension(390,22)); + // this is super critical - fixes bug where layout goes to hell if string are long + // in completion - dont ask me why???? + setMinimumSize(new Dimension(390,22)); AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); this.setEditor(autoTextFieldEditor); + // dont know why by setting fonts this seem to get worse not better in terms of + // the wierd layout issue with large terms & list //setFont(new Font("Courier",Font.PLAIN,12)); yuck //setFont(new Font("Lucida Console",Font.PLAIN,12)); not fixed - setFont(new Font("Lucida Typewriter",Font.PLAIN,10)); + //Font[] fonts = + //java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); + //for (Font f : fonts) System.out.println(f); + //setFont(new Font("Lucida Typewriter",Font.PLAIN,10)); + setFont(new Font("Monospaced",Font.PLAIN,10)); //setOntology(ontology); //searchParams = sp; // singleton access? part of ontology? compListSearcher = s; @@ -359,6 +368,16 @@ private JList getJList() { return listBox; // protected JList in BasicComboBoxUI } + // hmmmmmm - layout issues... actually the fix was to set the minimum size + // issue was with big terms screwing up layout +// public void layoutComboBox(java.awt.Container parent, MetalComboBoxLayoutManager manager ) { +// javax.swing.Icon icon = ((javax.swing.plaf.metal.MetalComboBoxButton)arrowButton).getComboIcon(); +// java.awt.Insets buttonInsets = arrowButton.getInsets(); +// java.awt.Insets insets = comboBox.getInsets(); +// int buttonWidth = icon.getIconWidth() + buttonInsets.left + buttonInsets.right; +// log().debug(" comb width "+comboBox.getWidth()+" inset right "+insets.right+" but width "+ buttonWidth+" in left "+insets.left+" l2r "+ comboBox.getComponentOrientation().isLeftToRight()+rectangleForCurrentValue()+editor.getBounds()); +// super.layoutComboBox(parent,manager); +// } } Modified: phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-16 16:03:41 UTC (rev 159) +++ phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-17 13:09:04 UTC (rev 160) @@ -35,16 +35,29 @@ } private String compListDisplayString() { - StringBuffer s = new StringBuffer(); - if (isSynMatch()) - s.append(synMatchString).append("[syn]"); - else - s.append(getName()); + StringBuffer display = new StringBuffer(); + StringBuffer appends = new StringBuffer(); + if (isSynMatch()) { + display.append(synMatchString); + appends.append("[syn]"); + } + else { + display.append(getName()); + } if (isDefinitionMatch()) - s.append("[def]"); + appends.append("[def]"); if (term.isObsolete()) - s.append("[obs]"); - return s.toString(); + appends.append("[obs]"); + // font metrics? fixed font? query length of Text gui? + // if in standalone mode should do fontmetrics + int allowedLength = 61 - appends.length(); // keep room for appends + if (display.length() > allowedLength) { + display.setLength(allowedLength-2); // -2 for ... ??? + display.append("..."); + } + //display = display.substring(0,allowedLength - 3); // -3 for ... + display.append(appends); + return display.toString(); } public String getID() { return term.getID(); } Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-16 16:03:41 UTC (rev 159) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-17 13:09:04 UTC (rev 160) @@ -164,7 +164,7 @@ frame = new JFrame("Phenote "+VERSION); // this may be changed to applet... frame.getContentPane().add(makeMainPanel()); MenuManager.createMenuManager(frame); - frame.setPreferredSize(new Dimension(1000,550)); + frame.setPreferredSize(new Dimension(1100,550)); if (standalone) // if stand alone exit java on window close frame.addWindowListener(new WindowExit()); frame.pack(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-16 16:03:51
|
Revision: 159 http://svn.sourceforge.net/obo/?rev=159&view=rev Author: mgibson Date: 2006-10-16 09:03:41 -0700 (Mon, 16 Oct 2006) Log Message: ----------- so now the completion list when a syn term is set the term name is what ends up in the box - what im discovering is im really sort of overworking JComboBox and having it go against its natural nature - and in hind sight i should just built my own - oh well - so on selection of a syn term the selection listener would listen and set the text field to the term name - BUT the JComboBox would subsequently (and also previously i think) set the text field as well and set it to the syn text in the selection - in other words what im doing is wierd having the selection and the subsequent text be different - but i noticed this was happening viea JComboBox.configureEditor - so i overrode & supressed that method entirely - i thought this may mess up other things but in testing it out it actually seems fine - if a bug does come out then the next step is to supress with a flag - and the flag is set in this particular completion case also fisxed bug where exact matches were coming in as "0" woops Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java phenote/trunk/src/java/phenote/gui/field/RelationCompList.java phenote/trunk/src/java/phenote/gui/field/TermCompList.java Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-13 19:08:49 UTC (rev 158) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2006-10-16 16:03:41 UTC (rev 159) @@ -7,6 +7,7 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.Vector; +import javax.swing.ComboBoxEditor; import javax.swing.JComboBox; import javax.swing.JList; import javax.swing.JTextField; @@ -71,9 +72,12 @@ setUI(new MetalListComboUI()); setEditable(true); setPreferredSize(new Dimension(350,22)); + setMaximumSize(new Dimension(350,22)); AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); this.setEditor(autoTextFieldEditor); - //setFont(new Font("Courier",Font.PLAIN,12)); + //setFont(new Font("Courier",Font.PLAIN,12)); yuck + //setFont(new Font("Lucida Console",Font.PLAIN,12)); not fixed + setFont(new Font("Lucida Typewriter",Font.PLAIN,10)); //setOntology(ontology); //searchParams = sp; // singleton access? part of ontology? compListSearcher = s; @@ -113,6 +117,8 @@ this.doCompletion = doCompletion; this.keyTyped = doCompletion; // key has to be typed for completion getEditor().setItem(text); + //log().debug("setting text "+text); + //new Throwable().printStackTrace(); this.doCompletion = true; // set back to default } @@ -138,7 +144,9 @@ /** BasicComboBoxEditor uses JTextField as its editing component but is * only available as a protected variable - odd - adds auto doc & auto key listeners to combo box edit field */ + adds auto doc & auto key listeners to combo box edit field + I think the purpose of this class is to set its editor var to AutoTextField + subclass of JTextField */ private class AutoTextFieldEditor extends BasicComboBoxEditor { private AutoTextFieldEditor() { @@ -181,8 +189,15 @@ // but this is needed from mouse release on selection set text // is called and will cause completion list to come up after sel // w/o it + //log().debug("AutoTextField.setText "+text); + //new Throwable().printStackTrace(); doCompletion = false; - super.setText(text); + //this is problematic for syns & such where string is diff than term name + // JComboBox sets this text AFTER got event and set to name + //super.setText(text); + // this works as only time setText is called with cngCL false is with + // selection - or at least so it seems + super.setText(getCurrentTermRelName()); doCompletion = true; } @@ -192,20 +207,12 @@ } } - public void simulateLKeyStroke() { - autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,KeyEvent.VK_L,'l')); - autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,'l')); - } - - public void simulateKeyStroke(int keyCode, char c) { - KeyEvent k = new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,keyCode,c); - autoTextField.processKeyEvent(k); - k.setKeyCode(KeyEvent.KEY_RELEASED); - autoTextField.processKeyEvent(k); - k = new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,c); - autoTextField.processKeyEvent(k); - } + + /** Return the name of the current term or relation - was gonna call this + item name but that gets confused with "items" in combo box */ + protected abstract String getCurrentTermRelName(); + private class AutoKeyListener extends KeyAdapter { // keyTyped doesnt seem to catch backspace in 1.5 - but did in 1.4 - odd // public void keyTyped(KeyEvent e) { @@ -402,6 +409,23 @@ throws ex if in fact current user input is not a valid item */ protected abstract void setCurrentValidItem() throws OboException; + /** Override - configureEditor is called when user selects item and sets text + field to item selected, unfortunately this happens after the listening + code in this class that sets to term name (not syn name), and then the syn + name gets set - so this is to catch & repress the subsequent syn name + setting - hope that makes sense heres the jdocs from JComboBox for this method: + Initializes the editor with the specified item. It seems to be ok as far + as i can tell to supress this method entirely - if this ends up being + problematic then this should be coulpled with a flag set in setCurrentValidItem + or a related method to supress the syn coming after term set */ + public void configureEditor(ComboBoxEditor anEditor,Object anItem) { + //log().debug("configure editor called"+anItem); + //new Throwable().printStackTrace(); + // it appears to be ok to supress this entirely + // super.configureEditor(anEditor,anItem); // ??? supress + } + + protected abstract void editModel(); private Logger log; @@ -409,6 +433,20 @@ if (log == null) log = Logger.getLogger(getClass()); return log; } + public void simulateLKeyStroke() { + autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,KeyEvent.VK_L,'l')); + autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,'l')); + } + + public void simulateKeyStroke(int keyCode, char c) { + KeyEvent k = new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,keyCode,c); + autoTextField.processKeyEvent(k); + k.setKeyCode(KeyEvent.KEY_RELEASED); + autoTextField.processKeyEvent(k); + k = new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,c); + autoTextField.processKeyEvent(k); + } + } class OboException extends Exception { Modified: phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2006-10-13 19:08:49 UTC (rev 158) +++ phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2006-10-16 16:03:41 UTC (rev 159) @@ -192,9 +192,10 @@ definitions.add(ct); // start with/contains? } - private void addTerm(CompletionTerm ct, List startsWith, List contains) { + private void addTerm(CompletionTerm ct, List<CompletionTerm> startsWith, + List<CompletionTerm> contains) { if (ct.isExactMatch()) // for syns as well? sure why not? - startsWith.add(0); + startsWith.add(0,ct); else if (ct.isStartsWithMatch()) startsWith.add(ct); else Modified: phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-13 19:08:49 UTC (rev 158) +++ phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-16 16:03:41 UTC (rev 159) @@ -8,13 +8,14 @@ /** This is basically a view object for the auto completer for terms/OBOClass */ public class CompletionTerm { - OBOClass term; - boolean termMatch = false; - boolean synonymMatch = false; - boolean definitionMatch = false; - boolean exactMatch = false; - boolean startsWith = false; - boolean contains = false; // do we need this? + private OBOClass term; + private boolean termMatch = false; + private boolean isSynMatch = false; + private String synMatchString; + private boolean definitionMatch = false; + private boolean exactMatch = false; + private boolean startsWith = false; + private boolean contains = false; // do we need this? CompletionTerm(OBOClass term) { this.term = term; @@ -23,7 +24,7 @@ OBOClass getOboClass() { return term; } boolean isTermMatch() { return termMatch; } - boolean isSynMatch() { return synonymMatch; } + boolean isSynMatch() { return isSynMatch; } boolean isDefinitionMatch() { return definitionMatch; } boolean isExactMatch() { return exactMatch; } @@ -34,7 +35,13 @@ } private String compListDisplayString() { - StringBuffer s = new StringBuffer(term.getName()); + StringBuffer s = new StringBuffer(); + if (isSynMatch()) + s.append(synMatchString).append("[syn]"); + else + s.append(getName()); + if (isDefinitionMatch()) + s.append("[def]"); if (term.isObsolete()) s.append("[obs]"); return s.toString(); @@ -64,7 +71,8 @@ for (Object o : getSyns()) { String syn = o.toString(); if (stringMatches(input,syn)) { - synonymMatch = true; + isSynMatch = true; + synMatchString = syn; return true; } } Modified: phenote/trunk/src/java/phenote/gui/field/RelationCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2006-10-13 19:08:49 UTC (rev 158) +++ phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2006-10-16 16:03:41 UTC (rev 159) @@ -39,6 +39,13 @@ setRel(getSelectedRelation()); } + protected String getCurrentTermRelName() { + if (currentRel!= null) + return currentRel.getName(); + else + return ""; + } + /** for relationships (post comp rel) */ void setRel(OBOProperty rel) { if (rel == null) { Modified: phenote/trunk/src/java/phenote/gui/field/TermCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2006-10-13 19:08:49 UTC (rev 158) +++ phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2006-10-16 16:03:41 UTC (rev 159) @@ -22,30 +22,11 @@ private OBOClass currentOboClass=null; TermCompList(CompListSearcher s,boolean editModel) { - super(s,editModel); enableTermInfoListening(); - // this inner class enables retrieving of JList for mouse over - // this will probably throw errors if non metal look & feel is used -// setUI(new MetalListComboUI()); -// //setFont(new Font("Courier",Font.PLAIN,12)); + } -// setOntology(ontology); -// searchParams = sp; // singleton access? part of ontology? -// setEditable(true); -// AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); -// this.setEditor(autoTextFieldEditor); -// setPreferredSize(new Dimension(350,22)); -// enableTermInfoListening(true); // default -// //addCompletionListListener(compList); - -// //if (editModel) // ComboBoxActionListener edits the model -// this.editModel = editModel; -// addActionListener(new ComboBoxActionListener()); - - } - protected Vector getSearchItems(String input) { return getCompListSearcher().getStringMatchTerms(input); } @@ -57,6 +38,13 @@ //currentOboClass = getSelectedOboClass(); } + protected String getCurrentTermRelName() { + if (currentOboClass!= null) + return currentOboClass.getName(); + else + return ""; + } + /** rename setTerm? */ void setOboClass(OBOClass term) { if (term == null) { @@ -99,15 +87,6 @@ return (CompletionTerm)obj; } -// // strings get in somehow - need to figure out where they are coming from -// private OBOClass oboClassDowncast(Object obj) throws OboException { -// if (obj == null) throw new OboException(); -// if ( ! (obj instanceof OBOClass)) { -// //log.info("Item in completion list not obo class "+obj.getClass()); -// throw new OboException("Item in completion list not obo class "+obj.getClass()); -// } -// return (OBOClass)obj; -// } protected void editModel() { OBOClass oboClass; @@ -167,7 +146,7 @@ //System.out.println("sel val "+selectedValue.getClass()+" name "+selectedValue); // the selected item should be an OBOClass if (!(selectedValue instanceof CompletionTerm)) { - log.debug("selected completion term is not CompTerm "+selectedValue.getClass()); + log().debug("selected completion term is not CompTerm "+selectedValue.getClass()); return; } CompletionTerm ct = (CompletionTerm)selectedValue; @@ -200,6 +179,33 @@ } } + // this inner class enables retrieving of JList for mouse over + // this will probably throw errors if non metal look & feel is used +// setUI(new MetalListComboUI()); +// //setFont(new Font("Courier",Font.PLAIN,12)); + +// setOntology(ontology); +// searchParams = sp; // singleton access? part of ontology? +// setEditable(true); +// AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); +// this.setEditor(autoTextFieldEditor); +// setPreferredSize(new Dimension(350,22)); + +// enableTermInfoListening(true); // default +// //addCompletionListListener(compList); + +// //if (editModel) // ComboBoxActionListener edits the model +// this.editModel = editModel; +// addActionListener(new ComboBoxActionListener()); +// // strings get in somehow - need to figure out where they are coming from +// private OBOClass oboClassDowncast(Object obj) throws OboException { +// if (obj == null) throw new OboException(); +// if ( ! (obj instanceof OBOClass)) { +// //log.info("Item in completion list not obo class "+obj.getClass()); +// throw new OboException("Item in completion list not obo class "+obj.getClass()); +// } +// return (OBOClass)obj; +// } // private OBOClass getCompListOboClass(int index) { // Object obj = defaultComboBoxModel.getElementAt(index); // return oboClassDowncast(obj); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-13 19:09:00
|
Revision: 158 http://svn.sourceforge.net/obo/?rev=158&view=rev Author: mgibson Date: 2006-10-13 12:08:49 -0700 (Fri, 13 Oct 2006) Log Message: ----------- now comp list sorts by exat term startsWith term contains term exact/startswith syn contains syn definitions obsoletes CompletionTerm now holds state of how it matched - startsWith, syn, defintion - which makes sorting this easier Modified Paths: -------------- phenote/trunk/src/java/phenote/datamodel/Ontology.java phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java Modified: phenote/trunk/src/java/phenote/datamodel/Ontology.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-12 18:33:48 UTC (rev 157) +++ phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-13 19:08:49 UTC (rev 158) @@ -79,6 +79,96 @@ return true; // no exception - it has it } + + public List<OBOProperty> getSortedRelations() { + if (sortedRelations == null) { + //sortedRelations=new ArrayList<OBOProperty>(); not Comparable! + List sorRel = new ArrayList(); + // if (oboSession == null) ? shouldnt happen + sorRel.addAll(oboSession.getRelationshipTypes()); + Collections.sort(sorRel,new RelComparator()); + sortedRelations = sorRel; // ? + } + return sortedRelations; + } + + private class RelComparator<OBOProperty> implements Comparator<OBOProperty> { + public int compare(OBOProperty r1, OBOProperty r2) { + return r1.toString().compareTo(r2.toString()); + } + public boolean equals(OBOProperty r1, OBOProperty r2) { + return r1.toString().equals(r2.toString()); + } + } + + + /** non obsolete terms - sorted */ + public List<OBOClass> getSortedTerms() { + return sortedTerms; + } + + public List<OBOClass> getSortedObsoleteTerms() { + return sortedObsoleteTerms; + } + + + private OBOSession getOboSession() { return oboSession; } + + public List<OBOClass> getSortedTerms(Set terms) { + List<OBOClass> sortedTerms = new ArrayList<OBOClass>(); + sortedTerms.addAll(terms); + Collections.sort(sortedTerms); + return sortedTerms; + } + + /** moght move this elsewhere - subclass? data adap specific wrapper? */ + public void setTimestamp(long t) { ontologyTimestamp = t; } + public long getTimestamp() { return ontologyTimestamp; } + /** for obo files this is the filename */ + public void setSource(String s) { source = s; } + public String getSource() { return source; } + + + + + public void setFilter(String filterOutString) { + this.filterOutString = filterOutString; + } + + private boolean haveFilter() { + //return filterOutString != null; + // minimally filter out obo: obo edit internal terms + return true; + } + + /** This is not generic - this looks for ids that have the filterOut string + as a prefix and tosses them - for example "ZFS" filters out all zf stage + terms - can add more flexibility as needed - this is all thats needed for now*/ + private List<OBOClass> filterList(List<OBOClass> list, String filterOut) { + List<OBOClass> filteredList = new ArrayList<OBOClass>(); + for (OBOClass term : list) { + // or could do remove on list? + // also filter out obo: terms as they are internal obo edit thingies it seems + // funny logic but more efficient to do in one pass - refactor somehow? + if (term.getName().startsWith("obo:")) + continue; // filter our obo: + if (filterOut != null && term.getID().startsWith(filterOut)) + continue; + filteredList.add(term); // passed 2 filters above - add it + } + return filteredList; + } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } +} + + + +// GARBAGE // /** Returns a Vector of OBOClass from ontology that contain input string // constrained by compParams. compParams specifies syns,terms,defs,& obs // should input be just part of search params? @@ -167,87 +257,6 @@ // } // return matches; // } - - public List<OBOProperty> getSortedRelations() { - if (sortedRelations == null) { - //sortedRelations=new ArrayList<OBOProperty>(); not Comparable! - List sorRel = new ArrayList(); - // if (oboSession == null) ? shouldnt happen - sorRel.addAll(oboSession.getRelationshipTypes()); - Collections.sort(sorRel,new RelComparator()); - sortedRelations = sorRel; // ? - } - return sortedRelations; - } - - private class RelComparator<OBOProperty> implements Comparator<OBOProperty> { - public int compare(OBOProperty r1, OBOProperty r2) { - return r1.toString().compareTo(r2.toString()); - } - public boolean equals(OBOProperty r1, OBOProperty r2) { - return r1.toString().equals(r2.toString()); - } - } - - - /** non obsolete terms - sorted */ - public List<OBOClass> getSortedTerms() { - return sortedTerms; - } - - public List<OBOClass> getSortedObsoleteTerms() { - return sortedObsoleteTerms; - } - - - private OBOSession getOboSession() { return oboSession; } - - public List<OBOClass> getSortedTerms(Set terms) { - List<OBOClass> sortedTerms = new ArrayList<OBOClass>(); - sortedTerms.addAll(terms); - Collections.sort(sortedTerms); - return sortedTerms; - } - - /** moght move this elsewhere - subclass? data adap specific wrapper? */ - public void setTimestamp(long t) { ontologyTimestamp = t; } - public long getTimestamp() { return ontologyTimestamp; } - /** for obo files this is the filename */ - public void setSource(String s) { source = s; } - public String getSource() { return source; } - - - - - public void setFilter(String filterOutString) { - this.filterOutString = filterOutString; - } - - private boolean haveFilter() { return filterOutString != null; } - - /** This is not generic - this looks for ids that have the filterOut string - as a prefix and tosses them - for example "ZFS" filters out all zf stage - terms - can add more flexibility as needed - this is all thats needed for now*/ - private List<OBOClass> filterList(List<OBOClass> list, String filterOut) { - List<OBOClass> filteredList = new ArrayList<OBOClass>(); - for (OBOClass term : list) { - // or could do remove on list? - if (!term.getID().startsWith(filterOut)) - filteredList.add(term); - } - return filteredList; - } - - private Logger log; - private Logger log() { - if (log == null) log = Logger.getLogger(getClass()); - return log; - } -} - - - -// GARBAGE // /** User input is already lower cased, this potentially adds oboClass to // * searchTerms if input & compareTerm match. Puts it first if exact. // * for term names comp = obo, for syns comp is the syn. Modified: phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2006-10-12 18:33:48 UTC (rev 157) +++ phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2006-10-13 19:08:49 UTC (rev 158) @@ -1,6 +1,7 @@ package phenote.gui.field; // complist package? field package? +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -68,51 +69,44 @@ private Vector<CompletionTerm> getSearchTerms(String input, List<OBOClass> ontologyTermList) { SearchTermList searchTermList = new SearchTermList(); - //Vector searchTerms = new Vector(); if (ontologyTermList == null) - return searchTermList.getVector();//searchTerms; + return searchTermList.getVector(); - boolean ignoreCase = true; // param? - if (ignoreCase) - input = input.toLowerCase(); + //boolean ignoreCase = true; // param? //if (ignoreCase) + //input = input.toLowerCase(); // done in CompletionTerm // i think iterators are more efficient than get(i) ?? Iterator<OBOClass> iter = ontologyTermList.iterator(); while (iter.hasNext()) { - // toString extracts name from OBOClass + OBOClass oboClass = iter.next(); - String originalTerm = oboClass.getName();//toString(); - - boolean termAdded = false; - if (searchParams.searchTerms()) { - // adds originalTerm to searchTerms if match (1st if exact) - termAdded = compareAndAddTerm(input,originalTerm,oboClass,searchTermList); - if (termAdded) - continue; + CompletionTerm ct = new CompletionTerm(oboClass); + if (ct.matches(input,searchParams)) { + searchTermList.addTerm(ct); } - - if (searchParams.searchSynonyms()) { - Set synonyms = oboClass.getSynonyms(); - for (Iterator i = synonyms.iterator(); i.hasNext() &&!termAdded; ) { - String syn = i.next().toString(); - //log().debug("syn "+syn+" for "+originalTerm); - termAdded = compareAndAddTerm(input,syn,oboClass,searchTermList); - //if (termAdded) continue; // woops continues this for not the outer! - } - } - if (termAdded) continue; - - - if (searchParams.searchDefinitions()) { - String definition = oboClass.getDefinition(); - if (definition != null & !definition.equals("")) - termAdded = compareAndAddTerm(input,definition,oboClass,searchTermList); - if (termAdded) - continue; // not really necesary as its last - } - +// String originalTerm = oboClass.getName();//toString(); +// boolean termAdded = false; +// if (searchParams.searchTerms()) { +// // adds originalTerm to searchTerms if match (1st if exact) +// termAdded = compareAndAddTerm(input,originalTerm,oboClass,searchTermList); +// if (termAdded) continue;} +// if (searchParams.searchSynonyms()) { +// Set synonyms = oboClass.getSynonyms(); +// for (Iterator i = synonyms.iterator(); i.hasNext() &&!termAdded; ) { +// String syn = i.next().toString(); +// //log().debug("syn "+syn+" for "+originalTerm); +// termAdded = compareAndAddTerm(input,syn,oboClass,searchTermList); +// //if (termAdded) continue; // woops continues this for not the outer! +// } +// } +// if (termAdded) continue; +// if (searchParams.searchDefinitions()) { +// String definition = oboClass.getDefinition(); +// if (definition != null & !definition.equals("")) +// termAdded = compareAndAddTerm(input,definition,oboClass,searchTermList); +// if (termAdded) continue; // not really necesary as its last } } return searchTermList.getVector(); } @@ -135,74 +129,108 @@ can be syn obs term or def and its lost here i think these methods need to be moved to gui.TermSearcher that utilizes Ontology but produces CompListTerms */ - private boolean compareAndAddTerm(String input, String compareTerm, OBOClass oboClass, - SearchTermList searchTermList) { +// private boolean compareAndAddTerm(String input, String compareTerm, OBOClass oboClass, +// SearchTermList searchTermList) { - String oboTerm = oboClass.getName(); +// //String oboTerm = oboClass.getName(); - String lowerComp = compareTerm; - boolean ignoreCase = true; // discard? param for? - if (ignoreCase) - lowerComp = compareTerm.toLowerCase(); +// String lowerComp = compareTerm; +// boolean ignoreCase = true; // discard? param for? +// if (ignoreCase) +// lowerComp = compareTerm.toLowerCase(); - //boolean doContains = true; // discard? param for? - // exact match goes first in list - if (lowerComp.equals(input)) { - searchTermList.addTermFirst(oboClass); // adds if not present - return true; - } - // new paradigm - put starts with first - else if (lowerComp.startsWith(input)) { - searchTermList.addTerm(oboClass); - return true; - } - // Contains - else if (contains(lowerComp,input) && !termFilter(lowerComp)) { - searchTermList.addContainsTerm(oboClass); - return true; - } - return false; - } +// //boolean doContains = true; // discard? param for? +// // exact match goes first in list +// if (lowerComp.equals(input)) { +// searchTermList.addTermFirst(oboClass); // adds if not present +// return true; +// } +// // new paradigm - put starts with first +// else if (lowerComp.startsWith(input)) { +// searchTermList.addTerm(oboClass); +// return true; +// } +// // Contains +// else if (contains(lowerComp,input)) { // && !termFilter(lowerComp) -> Ont +// searchTermList.addContainsTerm(oboClass); +// return true; +// } +// return false; +// } // 1.5 has a contains! use when we shift private boolean contains(String term, String input) { return term.contains(input); // 1.5!! //return term.indexOf(input) != -1; } - /** Oboedit getTerms returns some terms with obo: prefix that should be filtered - * out. Returns true if starts with obo: */ - private boolean termFilter(String term) { - return term.startsWith("obo:"); - } + // now done in Ontology.filterList() so dont have to check every time +// /** Oboedit getTerms returns some terms with obo: prefix that should be filtered +// * out. Returns true if starts with obo: */ +// private boolean termFilter(String term) { +// return term.startsWith("obo:"); // take these out of ontology? +// } /** this data structure is handy for putting starts with before contains! UniqueTermList -> SearchTermList*/ private class SearchTermList { - private Vector<CompletionTerm> searchTerms = new Vector<CompletionTerm>(); + private List<CompletionTerm> startsWithTerms = new ArrayList<CompletionTerm>(); //private Map<OBOClass,OBOClass> uniqueCheck = new HashMap<OBOClass,OBOClass>(); // list of terms that are contained but NOT startsWith - private Vector<CompletionTerm> containTerms = new Vector<CompletionTerm>(); - private void addTerm(OBOClass oboClass) { - addTerm(oboClass,false); + private List<CompletionTerm> containTerms = new ArrayList<CompletionTerm>(); + private List<CompletionTerm> startsWithSyns = new ArrayList<CompletionTerm>(); + private List<CompletionTerm> containSyns = new ArrayList<CompletionTerm>(); + private List<CompletionTerm> obsoletes = new ArrayList<CompletionTerm>(); + private List<CompletionTerm> definitions = new ArrayList<CompletionTerm>(); + + private void addTerm(CompletionTerm ct) { + if (ct.isObsolete()) + obsoletes.add(ct); // start with/contains? + else if (ct.isTermMatch()) + addTerm(ct,startsWithTerms,containTerms); + else if (ct.isSynMatch()) + addTerm(ct,startsWithSyns,containSyns); + else if (ct.isDefinitionMatch()) + definitions.add(ct); // start with/contains? } - private void addTermFirst(OBOClass oboClass) { - addTerm(oboClass,true); + + private void addTerm(CompletionTerm ct, List startsWith, List contains) { + if (ct.isExactMatch()) // for syns as well? sure why not? + startsWith.add(0); + else if (ct.isStartsWithMatch()) + startsWith.add(ct); + else + contains.add(ct); } - private void addTerm(OBOClass oboClass,boolean first) { - //if (uniqueCheck.containsKey(oboClass)) { - //log().debug("dup term in search "+oboClass); - // new Throwable().printStackTrace(); return; } - CompletionTerm t = new CompletionTerm(oboClass); - if (first) searchTerms.add(0,t); - else searchTerms.add(t); - //uniqueCheck.put(oboClass,null); // dont need value - } - /** Add term thats not startsWith but contains */ - private void addContainsTerm(OBOClass oboClass) { - containTerms.add(new CompletionTerm(oboClass)); - } + private Vector<CompletionTerm> getVector() { - searchTerms.addAll(containTerms); - return searchTerms; + //startsWithTerms.addAll(containTerms); return startsWithTerms; + Vector<CompletionTerm> sortedTerms = new Vector<CompletionTerm>(); + sortedTerms.addAll(startsWithTerms); + sortedTerms.addAll(containTerms); + sortedTerms.addAll(startsWithSyns); + sortedTerms.addAll(containSyns); + sortedTerms.addAll(definitions); + sortedTerms.addAll(obsoletes); + return sortedTerms; } } } + +// private void addTerm(OBOClass oboClass) { +// addTerm(oboClass,false); +// } +// private void addTermFirst(OBOClass oboClass) { +// addTerm(oboClass,true); +// } +// private void addTerm(OBOClass oboClass,boolean first) { +// //if (uniqueCheck.containsKey(oboClass)) { +// //log().debug("dup term in search "+oboClass); +// // new Throwable().printStackTrace(); return; } +// CompletionTerm t = new CompletionTerm(oboClass); +// if (first) startsWithTerms.add(0,t); +// else startsWithTerms.add(t); +// //uniqueCheck.put(oboClass,null); // dont need value +// } +// /** Add term thats not startsWith but contains */ +// private void addContainsTerm(OBOClass oboClass) { +// containTerms.add(new CompletionTerm(oboClass)); +// } Modified: phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-12 18:33:48 UTC (rev 157) +++ phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-13 19:08:49 UTC (rev 158) @@ -1,18 +1,34 @@ package phenote.gui.field; // completion package? +import java.util.Set; + import org.geneontology.oboedit.datamodel.OBOClass; /** This is basically a view object for the auto completer for terms/OBOClass */ public class CompletionTerm { OBOClass term; + boolean termMatch = false; + boolean synonymMatch = false; + boolean definitionMatch = false; + boolean exactMatch = false; + boolean startsWith = false; + boolean contains = false; // do we need this? + CompletionTerm(OBOClass term) { this.term = term; } OBOClass getOboClass() { return term; } + boolean isTermMatch() { return termMatch; } + boolean isSynMatch() { return synonymMatch; } + boolean isDefinitionMatch() { return definitionMatch; } + + boolean isExactMatch() { return exactMatch; } + boolean isStartsWithMatch() { return startsWith; } + public String toString() { return compListDisplayString(); } @@ -26,5 +42,59 @@ public String getID() { return term.getID(); } public String getName() { return term.getName(); } + private Set getSyns() { return term.getSynonyms(); } + private boolean hasDefinition() { + return getDefinition() != null && !getDefinition().equals(""); + } + private String getDefinition() { return term.getDefinition(); } + boolean isObsolete() { return term.isObsolete(); } + /** Returns true if term matches input according to searchParams. has + side effect of recording the kind of match - term, syn, desc... */ + boolean matches(String input, SearchParamsI searchParams) { + // TERMS + if (searchParams.searchTerms()) { + if (stringMatches(input,getName())) { + termMatch = true; // is this needed? + return true; + } + } + // SYNS + if (searchParams.searchSynonyms()) { + for (Object o : getSyns()) { + String syn = o.toString(); + if (stringMatches(input,syn)) { + synonymMatch = true; + return true; + } + } + } + // DEFS + if (searchParams.searchDefinitions() && hasDefinition()) { + if (stringMatches(input,getDefinition())) { + definitionMatch = true; + return true; + } + } + return false; + } + + private boolean stringMatches(String input, String item) { + input = input.toLowerCase().trim(); + item = item.toLowerCase().trim(); + if (input.equals(item)) { + exactMatch = true; + return true; + } + else if (item.startsWith(input)) { + startsWith = true; + return true; + } + else if (item.contains(input)) { + contains = true; + return true; + } + return false; // all above failed - no match + } + } Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-12 18:33:48 UTC (rev 157) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-13 19:08:49 UTC (rev 158) @@ -259,11 +259,11 @@ } public boolean searchSynonyms() { - return false; + return false; // --> true } public boolean searchDefinitions() { - return false; + return false; // ?? w [def]?? } /** @@ -271,7 +271,7 @@ * This should be in conjunction with the other 3 */ public boolean searchObsoletes() { - return false; + return false; // --> true w [obs], disallow selection } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-12 18:33:54
|
Revision: 157 http://svn.sourceforge.net/obo/?rev=157&view=rev Author: mgibson Date: 2006-10-12 11:33:48 -0700 (Thu, 12 Oct 2006) Log Message: ----------- adding [obs] at the end of obsolete terms in term completion utlimately this should be disallowed from being entered Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java Modified: phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-12 17:22:05 UTC (rev 156) +++ phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java 2006-10-12 18:33:48 UTC (rev 157) @@ -14,9 +14,16 @@ OBOClass getOboClass() { return term; } public String toString() { - return term.getName(); // ... + return compListDisplayString(); } + private String compListDisplayString() { + StringBuffer s = new StringBuffer(term.getName()); + if (term.isObsolete()) + s.append("[obs]"); + return s.toString(); + } + public String getID() { return term.getID(); } public String getName() { return term.getName(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-12 17:22:12
|
Revision: 156 http://svn.sourceforge.net/obo/?rev=156&view=rev Author: mgibson Date: 2006-10-12 10:22:05 -0700 (Thu, 12 Oct 2006) Log Message: ----------- adding ontologies spatial & relationship Added Paths: ----------- phenote/trunk/obo-files/relationship.obo phenote/trunk/obo-files/spatial.obo Added: phenote/trunk/obo-files/relationship.obo =================================================================== --- phenote/trunk/obo-files/relationship.obo (rev 0) +++ phenote/trunk/obo-files/relationship.obo 2006-10-12 17:22:05 UTC (rev 156) @@ -0,0 +1,218 @@ +format-version: 1.2 +date: 14:07:2006 00:00 +saved-by: cjm +auto-generated-by: cjm +default-namespace: relationship +remark: <p>This ontology contains logical relations to be shared across the different OBO ontologies. Each OBO ontology is free to extend this set with relations specific to the biology within that ontology</p><div class="notes"><p>In the definitions, variables c, d, ..., p, q, ... range over instances of continuants and processes respectively. C, D, ..., P, Q, ... range over the corresponding classes</p><p> For a discussion of instance-level relations and also of additional axioms needed to infer transitivity and other properties of the relations listed above see <a href="http://genomebiology.com/2005/6/5/R46">http://genomebiology.com/2005/6/5/R46</a> or the OBO relations page hosted at <a href="http://obo.sourceforge.net/relationship">http://obo.sourceforge.net/relationship</a></div> + +[Typedef] +id: OBO_REL:relationship +name: relationship +def: "A relationship between two classes (terms). Relationships between classes are expressed in terms of relations on underlying instances." [] + +[Typedef] +id: OBO_REL:is_a +name: is_a +builtin: true +def: "For continuants: C is_a C' if and only if: given any c that instantiates C at a time t, c instantiates C' at t. For processes: P is_a P' if and only if: that given any p that instantiates P, then p instantiates P'." [PMID:15892874] +comment: The is_a relationship is considered axiomatic by the obo file format specification, and by OWL +exact_synonym: "is_subtype_of" [] +xref_analog: owl:subClassOf +is_reflexive: true +is_anti_symmetric: true +is_transitive: true + +[Typedef] +id: OBO_REL:part_of +name: part_of +is_a: OBO_REL:relationship +def: "For continuants: C part_of C' if and only if: given any c that instantiates C at a time t, there is some c' such that c' instantiates C' at time t, and c *part_of* c' at t. For processes: P part_of P' if and only if: given any p that instantiates P at a time t, there is some p' such that p' instantiates P' at time t, and p *part_of* p' at t. (Here *part_of* is the instance-level part-relation.)" [PMID:15892874] +comment: Parthood as a relation between instances: The primitive instance-level relation p part_of p1 is illustrated in assertions such as: this instance of rhodopsin mediated phototransduction part_of this instance of visual perception. This relation satisfies at least the following standard axioms of mereology: reflexivity (for all p, p part_of p); anti-symmetry (for all p, p1, if p part_of p1 and p1 part_of p then p and p1 are identical); and transitivity (for all p, p1, p2, if p part_of p1 and p1 part_of p2, then p part_of p2). Analogous axioms hold also for parthood as a relation between spatial regions. For parthood as a relation between continuants, these axioms need to be modified to take account of the incorporation of a temporal argument. Thus for example the axiom of transitivity for continuants will assert that if c part_of c1 at t and c1 part_of c2 at t, then also c part_of c2 at t. Parthood as a relation between classes: To define part_of as a relation between classes we again need to distinguish the two cases of continuants and processes, even though the explicit reference to instants of time now falls away. For continuants, we have C part_of C1 if and only if any instance of C at any time is an instance-level part of some instance of C1 at that time, as for example in: cell nucleus part_ of cell. +inverse_of: OBO_REL:has_part +is_reflexive: true +is_anti_symmetric: true +is_transitive: true + +[Typedef] +id: OBO_REL:has_part +name: has_part +is_a: OBO_REL:relationship +inverse_of: OBO_REL:part_of +is_reflexive: true +is_anti_symmetric: true +is_transitive: true + +[Typedef] +id: OBO_REL:integral_part_of +name: integral_part_of +is_a: OBO_REL:part_of +def: "C integral_part_of C' if and only if: C part_of C' AND C' has_part C" [PMID:15892874] +inverse_of: OBO_REL:has_integral_part +is_reflexive: true +is_anti_symmetric: true +is_transitive: true + +[Typedef] +id: OBO_REL:has_integral_part +name: has_integral_part +is_a: OBO_REL:has_part +inverse_of: OBO_REL:integral_part_of +is_reflexive: true +is_anti_symmetric: true +is_transitive: true + +[Typedef] +id: OBO_REL:proper_part_of +name: proper_part_of +is_a: OBO_REL:part_of +def: "As for part_of, with the additional constraint that subject and object are distinct" [PMID:15892874] +inverse_of: OBO_REL:has_proper_part +is_transitive: true + +[Typedef] +id: OBO_REL:has_proper_part +name: has_proper_part +is_a: OBO_REL:has_part +inverse_of: OBO_REL:proper_part_of +is_transitive: true + +[Typedef] +id: OBO_REL:has_improper_part +name: has_improper_part +is_a: OBO_REL:has_part +inverse_of: OBO_REL:improper_part_of +is_reflexive: true +is_transitive: true + +[Typedef] +id: OBO_REL:improper_part_of +name: improper_part_of +is_a: OBO_REL:part_of +def: "As for part_of, with the additional constraint that subject and object may be identical" [PMID:15892874] +inverse_of: OBO_REL:has_improper_part +is_reflexive: true +is_transitive: true + +[Typedef] +id: OBO_REL:located_in +name: located_in +is_a: OBO_REL:relationship +def: "C located_in C' if and only if: given any c that instantiates C at a time t, there is some c' such that: c' instantiates C' at time t and c *located_in* c'. (Here *located_in* is the instance-level location relation.)" [PMID:15892874] +comment: Location as a relation between instances: The primitive instance-level relation c located_in r at t reflects the fact that each continuant is at any given time associated with exactly one spatial region, namely its exact location. Following we can use this relation to define a further instance-level location relation - not between a continuant and the region which it exactly occupies, but rather between one continuant and another. c is located in c1, in this sense, whenever the spatial region occupied by c is part_of the spatial region occupied by c1. Note that this relation comprehends both the relation of exact location between one continuant and another which obtains when r and r1 are identical (for example, when a portion of fluid exactly fills a cavity), as well as those sorts of inexact location relations which obtain, for example, between brain and head or between ovum and uterus +inverse_of: OBO_REL:location_of +is_transitive: true +is_reflexive: true + +[Typedef] +id: OBO_REL:location_of +name: location_of +is_a: OBO_REL:relationship +inverse_of: OBO_REL:located_in +is_transitive: true +is_reflexive: true + +[Typedef] +id: OBO_REL:contained_in +name: contained_in +is_a: OBO_REL:relationship +inverse_of: OBO_REL:contains +def: "C contained_in C' if and only if: given any instance c that instantiates C at a time t, there is some c' such that: c' instantiates C' at time t and c located_in c' at t, and it is not the case that c *overlaps* c' at t. (c' is a conduit or cavity.)" [PMID:15892874] +comment: Containment obtains in each case between material and immaterial continuants, for instance: lung contained_in thoracic cavity; bladder contained_in pelvic cavity. Hence containment is not a transitive relation. If c part_of c1 at t then we have also, by our definition and by the axioms of mereology applied to spatial regions, c located_in c1 at t. Thus, many examples of instance-level location relations for continuants are in fact cases of instance-level parthood. For material continuants location and parthood coincide. Containment is location not involving parthood, and arises only where some immaterial continuant is involved. To understand this relation, we first define overlap for continuants as follows: c1 overlap c2 at t =def for some c, c part_of c1 at t and c part_of c2 at t. The containment relation on the instance level can then be defined (see definition): + +[Typedef] +id: OBO_REL:contains +name: contains +is_a: OBO_REL:relationship +inverse_of: OBO_REL:contained_in + +[Typedef] +id: OBO_REL:adjacent_to +name: adjacent_to +is_a: OBO_REL:relationship +def: "C adjacent to C' if and only if: given any instance c that instantiates C at a time t, there is some c' such that: c' instantiates C' at time t and c and c' are in spatial proximity" [PMID:15892874] +comment: Note that adjacent_to as thus defined is not a symmetric relation, in contrast to its instance-level counterpart. For it can be the case that Cs are in general such as to be adjacent to instances of C1 while no analogous statement holds for C1s in general in relation to instances of C. Examples are: nuclear membrane adjacent_to cytoplasm; seminal vesicle adjacent_to urinary bladder; ovary adjacent_to parietal pelvic peritoneum + +[Typedef] +id: OBO_REL:transformation_of +name: transformation_of +is_a: OBO_REL:relationship +def: "Relation between two classes, in which instances retain their identity yet change their classification by virtue of some kind of transformation. Formally: C transformation_of C' if and only if given any c and any t, if c instantiates C at time t, then for some t', c instantiates C' at t' and t' earlier t, and there is no t2 such that c instantiates C at t2 and c instantiates C' at t2." [PMID:15892874] +comment: When an embryonic oenocyte (a type of insect cell) is transformed into a larval oenocyte, one and the same continuant entity preserves its identity while instantiating distinct classes at distinct times. The class-level relation transformation_of obtains between continuant classes C and C1 wherever each instance of the class C is such as to have existed at some earlier time as an instance of the distinct class C1 (see Figure 2 in paper). This relation is illustrated first of all at the molecular level of granularity by the relation between mature RNA and the pre-RNA from which it is processed, or between (UV-induced) thymine-dimer and thymine dinucleotide. At coarser levels of granularity it is illustrated by the transformations involved in the creation of red blood cells, for example, from reticulocyte to erythrocyte, and by processes of development, for example, from larva to pupa, or from (post-gastrular) embryo to fetus or from child to adult. It is also manifest in pathological transformations, for example, of normal colon into carcinomatous colon. In each such case, one and the same continuant entity instantiates distinct classes at different times in virtue of phenotypic changes. +inverse_of: OBO_REL:transformed_into +is_transitive: true + +[Typedef] +id: OBO_REL:transformed_into +name: transformed_into +is_a: OBO_REL:relationship +inverse_of: OBO_REL:transformation_of +is_transitive: true + +[Typedef] +id: OBO_REL:derives_from +name: derives_from +is_a: OBO_REL:relationship +def: "Derivation on the instance level (*derives_from*) holds between distinct material continuants when one succeeds the other across a temporal divide in such a way that at least a biologically significant portion of the matter of the earlier continuant is inherited by the later. We say that one class C derives_from class C' if instances of C are connected to instances of C' via some chain of instance-level derivation relations. Example: osteocyte derives_from osteoblast. Formally: C derives_immediately_from C' if and only if: given any c and any t, if c instantiates C at time t, then there is some c' and some t', such that c' instantiates C' at t' and t' earlier-than t and c *derives_from* c'. C derives_from C' if and only if: there is an chain of immediate derivation relations connecting C to C'." [PMID:15892874] +comment: Derivation as a relation between instances. The temporal relation of derivation is more complex. Transformation, on the instance level, is just the relation of identity: each adult is identical to some child existing at some earlier time. Derivation on the instance-level is a relation holding between non-identicals. More precisely, it holds between distinct material continuants when one succeeds the other across a temporal divide in such a way that at least a biologically significant portion of the matter of the earlier continuant is inherited by the later. Thus we will have axioms to the effect that from c derives_from c1 we can infer that c and c1 are not identical and that there is some instant of time t such that c1 exists only prior to and c only subsequent to t. We will also be able to infer that the spatial region occupied by c as it begins to exist at t overlaps with the spatial region occupied by c1 as it ceases to exist in the same instant. +inverse_of: OBO_REL:derived_into +is_transitive: true + +[Typedef] +id: OBO_REL:derived_into +name: derived_into +is_a: OBO_REL:relationship +inverse_of: OBO_REL:derives_from +is_transitive: true + +[Typedef] +id: OBO_REL:preceded_by +name: preceded_by +is_a: OBO_REL:relationship +def: "P preceded_by P' if and only if: given any process p that instantiates P at a time t, there is some process p' such that p' instantiates P' at time t', and t' is earlier than t. " [PMID:15892874] +comment: An example is: translation preceded_by transcription; aging preceded_by development (not however death preceded_by aging). Where derives_from links classes of continuants, preceded_by links classes of processes. Clearly, however, these two relations are not independent of each other. Thus if cells of type C1 derive_from cells of type C, then any cell division involving an instance of C1 in a given lineage is preceded_by cellular processes involving an instance of C. The assertion P preceded_by P1 tells us something about Ps in general: that is, it tells us something about what happened earlier, given what we know about what happened later. Thus it does not provide information pointing in the opposite direction, concerning instances of P1 in general; that is, that each is such as to be succeeded by some instance of P. Note that an assertion to the effect that P preceded_by P1 is rather weak; it tells us little about the relations between the underlying instances in virtue of which the preceded_by relation obtains. Typically we will be interested in stronger relations, for example in the relation immediately_preceded_by, or in relations which combine preceded_by with a condition to the effect that the corresponding instances of P and P1 share participants, or that their participants are connected by relations of derivation, or (as a first step along the road to a treatment of causality) that the one process in some way affects (for example, initiates or regulates) the other. +inverse_of: OBO_REL:precedes +is_transitive: true + +[Typedef] +id: OBO_REL:precedes +name: precedes +is_a: OBO_REL:relationship +inverse_of: OBO_REL:preceded_by +is_transitive: true + +[Typedef] +id: OBO_REL:has_participant +name: has_participant +is_a: OBO_REL:relationship +def: "P has_participant C if and only if: given any process p that instantiates P there is some continuant c, and some time t, such that: c instantiates C at t and c participates in p at t" [PMID:15892874] +comment: Has_participant is a primitive instance-level relation between a process, a continuant, and a time at which the continuant participates in some way in the process. The relation obtains, for example, when this particular process of oxygen exchange across this particular alveolar membrane has_participant this particular sample of hemoglobin at this particular time. +inverse_of: OBO_REL:participates_in + +[Typedef] +id: OBO_REL:participates_in +name: participates_in +is_a: OBO_REL:relationship +inverse_of: OBO_REL:has_participant + +[Typedef] +id: OBO_REL:has_agent +name: has_agent +is_a: OBO_REL:relationship +def: "As for has_participant, but with the additional condition that the component instance is causally active in the relevant process" [PMID:15892874] +inverse_of: OBO_REL:agent_in + +[Typedef] +id: OBO_REL:agent_in +name: agent_in +is_a: OBO_REL:relationship +inverse_of: OBO_REL:has_agent + +[Typedef] +id: OBO_REL:instance_of +name: instance_of +builtin: true +is_a: OBO_REL:relationship +def: "A relation between an instance and a class. For components: a primitive relation between a component instance and a class which it instantiates at a specific time. For processes: a primitive relation, between a process instance and a class which it instantiates, holding independently of time" [PMID:15892874] +comment: The instance_of relationship is considered axiomatic by the obo file format specification; ie it is taken for granted. The is_a relation is still included in this ontology for completeness + + Added: phenote/trunk/obo-files/spatial.obo =================================================================== --- phenote/trunk/obo-files/spatial.obo (rev 0) +++ phenote/trunk/obo-files/spatial.obo 2006-10-12 17:22:05 UTC (rev 156) @@ -0,0 +1,586 @@ +format-version: 1.2 +date: 03:04:2005 17:49 +default-namespace: spatial +autogenerated-by: /Users/cjm/cvs/go-dev/go-perl/scripts/go2fmt.pl +remark: based on FBql + +[Term] +id: BSPO:0000010 +name: anatomical axis +namespace: spatial +def: "A straight line through space, intersecting an anatomical entity, around which it can be rotated" [] + +[Term] +id: BSPO:0000051 +name: anatomical gradient +namespace: spatial +def: "A region defined by change in the value of some quantity per unit of distance across some spatial axis" [] +xref_analog: FBql:00005254 + +[Term] +id: BSPO:0000070 +name: anatomical region +namespace: spatial +def: "A 3D region in space without well-defined compartmental boundaries; for example, the dorsal region of an ectoderm" [] +xref_analog: FBql:00005841 + +[Term] +id: BSPO:0000054 +name: anatomical axis direction +namespace: spatial +def: "A direction along an anatomical axis" [] +xref_analog: FBql:00005841 + +[Term] +id: BSPO:0000005 +name: anatomical surface +namespace: spatial +def: "A 2D surface of an anatomical continuant" [] + +[Term] +id: BSPO:0000200 +name: anatomical cross-section +namespace: spatial +definition: "A 2D planar region intersecting an anatomical entity perpendicular to an anatomical axis" + +[Term] +id: BSPO:0000092 +name: anatomical compartment boundary +namespace: spatial +xref_analog: FBql:00005881 + +[Term] +id: BSPO:0000086 +name: anatomical compartment +namespace: spatial +xref_analog: FBql:00005873 + +[Term] +id: BSPO:0000011 +name: upper/lower axis +namespace: spatial +is_a: BSPO:0000010 +def: "An anatomical axis determined by gravity" [] + +[Term] +id: BSPO:0000012 +name: deep/superficial axis +namespace: spatial +is_a: BSPO:0000010 + +[Term] +id: BSPO:0000013 +name: anterior/posterior axis +namespace: spatial +is_a: BSPO:0000010 + +[Term] +id: BSPO:0000014 +name: apical/basal axis +namespace: spatial +is_a: BSPO:0000010 + +[Term] +id: BSPO:0000015 +name: proximal/distal axis +namespace: spatial +is_a: BSPO:0000010 + +[Term] +id: BSPO:0000016 +name: dorsal/ventral axis +namespace: spatial +is_a: BSPO:0000010 + +[Term] +id: BSPO:0000052 +name: anterior-posterior gradient +namespace: spatial +is_a: BSPO:0000051 +intersection_of: BSPO:0000051 +intersection_of: has_axis BSPO:0000013 +xref_analog: FBql:00005256 + +[Term] +id: BSPO:0000053 +name: dorsal-ventral gradient +namespace: spatial +is_a: BSPO:0000051 +intersection_of: BSPO:0000051 +intersection_of: has_axis BSPO:0000016 +xref_analog: FBql:00005255 + +[Term] +id: BSPO:0000020 +name: upper-lower gradient +namespace: spatial +is_a: BSPO:0000051 +intersection_of: BSPO:0000051 +intersection_of: has_axis BSPO:0000011 + +[Term] +id: BSPO:00000021 +name: deep-superficial gradient +namespace: spatial +is_a: BSPO:0000051 +intersection_of: BSPO:0000051 +intersection_of: has_axis BSPO:0000012 + +[Term] +id: BSPO:0000023 +name: apical-basal gradient +namespace: spatial +intersection_of: BSPO:0000051 +intersection_of: has_axis BSPO:0000014 +is_a: BSPO:0000051 + +[Term] +id: BSPO:0000024 +name: proximal-distal gradient +namespace: spatial +is_a: BSPO:0000051 +intersection_of: BSPO:0000051 +intersection_of: has_axis BSPO:0000015 + +[Term] +id: BSPO:0000001 +name: upper +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000011 +!relationship: has_directionality contra + +[Term] +id: BSPO:0000002 +name: lower +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000011 + +[Term] +id: BSPO:0000003 +name: deep +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000012 + +[Term] +id: BSPO:0000004 +name: superficial +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000012 + +[Term] +id: BSPO:0000055 +name: anterior +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000013 +xref_analog: FBql:00005848 + +[Term] +id: BSPO:0000056 +name: posterior +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005849 +relationship: has_axis BSPO:0000013 + +[Term] +id: BSPO:0000057 +name: apical +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000014 +xref_analog: FBql:00005854 + +[Term] +id: BSPO:0000058 +name: basal +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000014 +xref_analog: FBql:00005855 + +[Term] +id: BSPO:0000059 +name: central +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00015851 + +[Term] +id: BSPO:0000060 +name: contralateral +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005851 + +[Term] +id: BSPO:0000061 +name: proximal +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000015 +xref_analog: FBql:00005852 + +[Term] +id: BSPO:0000062 +name: distal +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005853 +relationship: has_axis BSPO:0000015 + +[Term] +id: BSPO:0000063 +name: dorsal +namespace: spatial +is_a: BSPO:0000054 +relationship: has_axis BSPO:0000016 +xref_analog: FBql:00005842 + +[Term] +id: BSPO:0000065 +name: ipsilateral +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005850 + +[Term] +id: BSPO:0000066 +name: lateral +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005844 + +[Term] +id: BSPO:0000067 +name: medial +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005847 + +[Term] +id: BSPO:0000068 +name: ventral +namespace: spatial +is_a: BSPO:0000054 +xref_analog: FBql:00005843 +relationship: has_axis BSPO:0000016 + +[Term] +id: BSPO:0000031 +name: upper region +namespace: spatial +is_a: BSPO:0000070 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000001 + +[Term] +id: BSPO:0000032 +name: lower region +namespace: spatial +is_a: BSPO:0000070 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000002 + +[Term] +id: BSPO:0000033 +name: deep region +namespace: spatial +is_a: BSPO:0000070 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000003 + +[Term] +id: BSPO:0000034 +name: superficial region +namespace: spatial +is_a: BSPO:0000070 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000004 + +[Term] +id: BSPO:0000071 +name: anterior region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005848 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000055 + +[Term] +id: BSPO:0000072 +name: posterior region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005849 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000056 + +[Term] +id: BSPO:0000073 +name: apical region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005854 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000057 + +[Term] +id: BSPO:0000074 +name: basal region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005855 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000058 + +[Term] +id: BSPO:0000075 +name: central region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00015851 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000059 + +[Term] +id: BSPO:0000076 +name: contralateral region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005851 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000060 + +[Term] +id: BSPO:0000077 +name: proximal region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005852 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000061 + +[Term] +id: BSPO:0000078 +name: distal region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005853 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000062 + +[Term] +id: BSPO:0000079 +name: dorsal region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005842 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000063 + +[Term] +id: BSPO:0000080 +name: dorso-lateral region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005845 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000063 +intersection_of: has_position BSPO:0000066 + +[Term] +id: BSPO:0000081 +name: ipsilateral region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005850 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000065 + +[Term] +id: BSPO:0000082 +name: lateral region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005844 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000066 + +[Term] +id: BSPO:0000083 +name: medial region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005847 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000067 + +[Term] +id: BSPO:0000084 +name: ventral region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005843 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000068 + +[Term] +id: BSPO:0000085 +name: ventro-lateral region +namespace: spatial +is_a: BSPO:0000070 +xref_analog: FBql:00005846 +intersection_of: BSPO:0000070 +intersection_of: has_position BSPO:0000068 +intersection_of: has_position BSPO:0000066 +comment: This is an example of a composition of two axis positions + +[Term] +id: BSPO:0000087 +name: anterior compartment +namespace: spatial +is_a: BSPO:0000086 +xref_analog: FBql:00005874 + +[Term] +id: BSPO:0000088 +name: compartment boundary +namespace: spatial +is_a: BSPO:0000086 +xref_analog: FBql:00005878 + +[Term] +id: BSPO:0000089 +name: dorsal compartment +namespace: spatial +is_a: BSPO:0000086 +xref_analog: FBql:00005876 + +[Term] +id: BSPO:0000090 +name: posterior compartment +namespace: spatial +is_a: BSPO:0000086 +xref_analog: FBql:00005875 + +[Term] +id: BSPO:0000091 +name: ventral compartment +namespace: spatial +is_a: BSPO:0000086 +xref_analog: FBql:00005877 + +[Term] +id: BSPO:0000093 +name: anterior/posterior compartment boundary +namespace: spatial +is_a: BSPO:0000092 +xref_analog: FBql:00005880 + +[Term] +id: BSPO:0000094 +name: dorsal/ventral compartment boundary +namespace: spatial +is_a: BSPO:0000092 +xref_analog: FBql:00005879 + +[Term] +id: BSPO:0000040 +name: upper/lower compartment boundary +namespace: spatial +is_a: BSPO:0000092 + +[Term] +id: BSPO:0000041 +name: deep/superficial compartment boundary +namespace: spatial +is_a: BSPO:0000092 + +[Term] +id: BSPO:0000043 +name: apical/basal compartment boundary +namespace: spatial +is_a: BSPO:0000092 + +[Term] +id: BSPO:0000044 +name: proximal/distal compartment boundary +namespace: spatial +is_a: BSPO:0000092 + +[Typedef] +id: BSPO:0000095 +name: anatomical_relation +namespace: spatial +xref_analog: FBql:00005860 + +[Typedef] +id: BSPO:0000096 +name: anterior_to +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005863 + +[Typedef] +id: BSPO:0000097 +name: distal_to +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005867 + +[Typedef] +id: BSPO:0000098 +name: dorsal_to +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005865 + +[Typedef] +id: BSPO:0000099 +name: posterior_to +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005864 + +[Typedef] +id: BSPO:0000100 +name: proximal_to +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005868 + +[Typedef] +id: BSPO:0000101 +name: surrounding +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005861 + +[Typedef] +id: BSPO:0000102 +name: ventral_to +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005866 + +[Typedef] +id: BSPO:0000103 +name: vicinity_of +namespace: spatial +is_a: BSPO:0000095 +xref_analog: FBql:00005862 + +[Typedef] +id: has_axis +name: has_axis +namespace: spatial + +[Typedef] +id: has_position +name: has_position +namespace: spatial \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-12 17:02:09
|
Revision: 155 http://svn.sourceforge.net/obo/?rev=155&view=rev Author: mgibson Date: 2006-10-12 10:02:05 -0700 (Thu, 12 Oct 2006) Log Message: ----------- hope this fixes my funny svn state hmmmmm Removed Paths: ------------- phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java Deleted: phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java 2006-10-12 17:01:27 UTC (rev 154) +++ phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java 2006-10-12 17:02:05 UTC (rev 155) @@ -1,552 +0,0 @@ -package phenote.gui; - -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.util.Vector; -import javax.swing.JComboBox; -import javax.swing.JList; -import javax.swing.JTextField; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.DefaultComboBoxModel; -import javax.swing.text.Document; -import javax.swing.plaf.basic.BasicComboBoxEditor; -//import javax.swing.plaf.basic.BasicComboBoxUI; -import javax.swing.plaf.ComboBoxUI; -import javax.swing.plaf.metal.MetalComboBoxUI; - -import org.apache.log4j.Logger; - -import org.geneontology.oboedit.datamodel.OBOClass; -import org.geneontology.oboedit.datamodel.OBOProperty; - -import phenote.datamodel.CharField; -import phenote.datamodel.CharFieldEnum; -import phenote.datamodel.CharacterI; -//import phenote.datamodel.Ontology; -import phenote.edit.EditManager; -import phenote.edit.UpdateTransaction; -import phenote.gui.selection.SelectionManager; -import phenote.gui.selection.UseTermEvent; -import phenote.gui.selection.UseTermListener; - -/** The jcombobox that does auto completion - i had to do some tricks(hacks) to get it - working with mouse over which doesnt come naturally to jcombobox */ - -class AbstractAutoCompList extends JComboBox { - - //private Ontology ontology; - private boolean changingCompletionList = false; - private boolean keyTyped = false; - private String previousInput = ""; - private boolean doCompletion = true; - // should we keep state of currentOboClass which is null if not a valid one? - // default combo box.getSelectedItem sortof does this imperfectly - //private OBOClass currentOboClass=null; - //private OBOProperty currentRel=null; - private DefaultComboBoxModel defaultComboBoxModel; - //private SearchParamsI searchParams; - private boolean inTestMode = false; - //private AutoTextFieldEditor autoTextFieldEditor; - private AutoTextField autoTextField; - private CharField charField; - ///** Whether differentia of a post composed term */ - //private boolean isDifferentia = false; - /** if false then model is not edited */ - private boolean editModel; - private CompletionListListener compListListener = new CompletionListListener(); - private CompListSearcher compListSearcher; - - /** @param editModel if false then ACB doesnt edit model directly (post comp) - can abstract classes have constructors - if not init() */ - protected AbstractAutoCompList(CompListSearcher s,boolean editModel) { - // this inner class enables retrieving of JList for mouse over - // this will probably throw errors if non metal look & feel is used - setUI(new MetalListComboUI()); - setEditable(true); - setPreferredSize(new Dimension(350,22)); - AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); - this.setEditor(autoTextFieldEditor); - //setFont(new Font("Courier",Font.PLAIN,12)); - //setOntology(ontology); - //searchParams = sp; // singleton access? part of ontology? - compListSearcher = s; - enableTermInfoListening(true); // default - //addCompletionListListener(compList); - //if (editModel) // ComboBoxActionListener edits the model - this.editModel = editModel; - addActionListener(new ComboBoxActionListener()); - - } - - //void setOntology(Ontology o) { ontology = o; } - - //void setSearchParams(SearchParamsI sp) { searchParams = sp; } - - void setCharField(CharField charField) { this.charField = charField; } - - ///** If true than the auto combo is for setting the differentia in a post comp term, - // if false (default) than no post comp or genus in post comp */ - //void setIsDifferentia(boolean isDiff) { isDifferentia = isDiff; } - - /** Set text in editable text field of j combo (eg from table select) */ - void setText(String text) { - // do not do term completion on externally set text! - boolean doCompletion = false; - setText(text,doCompletion); - } - - /** text from selecting table doesnt do completion, TestPhenote does */ - void setText(String text, boolean doCompletion) { - this.doCompletion = doCompletion; - this.keyTyped = doCompletion; // key has to be typed for completion - getEditor().setItem(text); - this.doCompletion = true; // set back to default - } - - - /** Return text in text field */ - String getText() { - //return (String)getSelectedItem(); - return getEditor().getItem().toString(); // or editor.getText() ? - } - - - void clear() { - setText(""); - } - - protected Object getSelectedObject() throws OboException { - if (defaultComboBoxModel == null) throw new OboException(); // ?? - Object obj = defaultComboBoxModel.getSelectedItem(); - if (obj == null) throw new OboException(); - return obj; - } - - - /** BasicComboBoxEditor uses JTextField as its editing component but is - * only available as a protected variable - odd - adds auto doc & auto key listeners to combo box edit field */ - private class AutoTextFieldEditor extends BasicComboBoxEditor { - - private AutoTextFieldEditor() { - autoTextField = new AutoTextField(); // outer instance var for testing - editor = autoTextField; // protected editor var from BCBE - addDocumentListener(new AutoDocumentListener()); - getTextField().addKeyListener(new AutoKeyListener()); - } - - // editor is protected JTextField - wacky - private JTextField getTextField() { - return editor; - } - - private Document getDocument() { - return getTextField().getDocument(); - } - private void addDocumentListener(DocumentListener dl) { - getDocument().addDocumentListener(dl); - } - } - - - /** AutoTextField inner class - ignores set text when in - * changingCompletionList mode - this is the text field for the - combo box */ - private class AutoTextField extends JTextField { - - private AutoTextField() { - super(25); // width - } - - /** dont set text if changing completion list, if changing text turn off - completion, as changing text is coming from outside not user typing - thus wont get completion on user selection, leaving popup hanging */ - public void setText(String text) { - if (changingCompletionList) - return; - // this makes setText(text,true) turn to false (called from TextPhenote) - // but this is needed from mouse release on selection set text - // is called and will cause completion list to come up after sel - // w/o it - doCompletion = false; - super.setText(text); - doCompletion = true; - } - - protected void processKeyEvent(KeyEvent e) { - //boolean fiddle = KeyboardState.shouldProcess(e); - super.processKeyEvent(e); - } - } - - void simulateLKeyStroke() { - autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,KeyEvent.VK_L,'l')); - autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,'l')); - } - - void simulateKeyStroke(int keyCode, char c) { - KeyEvent k = new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,keyCode,c); - autoTextField.processKeyEvent(k); - k.setKeyCode(KeyEvent.KEY_RELEASED); - autoTextField.processKeyEvent(k); - k = new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,c); - autoTextField.processKeyEvent(k); - } - - private class AutoKeyListener extends KeyAdapter { - // keyTyped doesnt seem to catch backspace in 1.5 - but did in 1.4 - odd -// public void keyTyped(KeyEvent e) { -// // return & tab should be ignored, as well as a lot of other things -// keyTyped = true; -// // this may be funny but with key type event the text has not yet be set -// // this catches cases where text changed due select/action - kinda cheap -// previousInput = getText(); -// } - public void keyReleased(KeyEvent e) { - // return & tab should be ignored, as well as a lot of other things - keyTyped = true; - // this may be funny but with key type event the text has not yet be set - // this catches cases where text changed due select/action - kinda cheap - previousInput = getText(); - } - } - - - /** disable completion for item being selected - otherwise a popup comes up after - the selection - probably no harm in keeping this but this may be redundant with - the turning off of doCompletion in inner ATF.setText which is more - comprehensive */ - public void setSelectedItem(Object item) { - doCompletion = false; - super.setSelectedItem(item); - doCompletion = true; - } - - /** If combo box is relationship then the items will be OBOProperties not - OBOClasses */ - private boolean isRelationshipList() { - return charField.isRelationship(); - } - private boolean isTermList() { return !isRelationshipList(); } - - /** MAKE COMPLETION LIST FROM USER INPUT - Populates defaultComboBoxModel with Vector of OBOClasses - OBOClass.toString - is the name of the term - thats why its possible - at least for moment - if we want to put syn in brackets that makes this not possible - certainly - handy */ - private void doCompletion() { - if (!doCompletion) // flag set if text filled in externally (from table sel) - return; - // so AbstractDoc.replace does a remove and then insert, the remove sets - // text to "" and then keyTyped gets set to false, so the insert doesnt go - // through, taking out keyTyped, inputChanged may be sufficient -// if (!keyTyped) // if user hasnt typed anything dont bother -// return; - if (!inputChanged()) // if input is actually same no need to recomp - return; - keyTyped = false; - // too soon - text field doesnt have text yet.... hmmmm.... - String input = getText(); - // this is a vector of OBOClasses - // i think ultimately we will need to wrap the OBOClass to be able to - // have more control over the string - cut off w ... & [syn][obs] tags - // returns a vector of CompletionTerms (checks if relations) - Vector v = getTerms(input); // abstract method - //if (isRelationshipList()) v = ontology.getStringMatchRelations(input); - //else v = getTerms(input); - // throws IllegalStateException, Attempt to mutate in notification - // this tries to change text field amidst notification hmmmm..... - changingCompletionList = true; - defaultComboBoxModel = new DefaultComboBoxModel(v); - setModel(defaultComboBoxModel); - changingCompletionList = false; - // showPopup can hang during test but not during real run - bizarre - showPopup(); // only show popup on key events - actually only do comp w key - } - - /** This is cheesy but theres a hanging bug with showPopup that only happens - in test mode - dont know why but doesnt actually matter, so setting flag - to turn off showpopup in test - if hangs in nontest will investigate */ - void setTestMode(boolean inTestMode) { - this.inTestMode = inTestMode; - } - - /** This is cheesy but theres a hanging bug with showPopup that only happens - in test mode - dont know why but doesnt actually matter, so if inTestMode - then dont showpopup - if hangs in nontest will investigate */ - public void showPopup() { - if (inTestMode) - return; - super.showPopup(); - } - - - /** returns true if input changed from previously recorded input */ - private boolean inputChanged() { - String newInput = getText(); - boolean inputChanged = ! previousInput.equals(newInput); - if (inputChanged) - previousInput = newInput; - return inputChanged; - } - - /** call Ontology to get a Vector of OBOClass's that contain "in" - in ontology */ -// private Vector<OBOClass> getTermsOld(String in) { -// // or CompletionList.getCompletionList(getOntology()) ?? -// //CompletionList cl = CompletionList.getCompletionList(); -// //return cl.getCompletionTerms(getOntology(),in,searchParams); -// return ontology.getSearchTerms(in,searchParams); // vector of OBOClass's -// } - - // Vector<CompletionTerm>? CompletionItem? - protected abstract Vector getTerms(String input); -// if (isRelationshipList()) return termSearcher.getStringMatchRelations(input); -// else return termSearcher.getStringMatchTerms(input);} - - private class AutoDocumentListener implements DocumentListener { - public void changedUpdate(DocumentEvent e) { doCompletion(); } - public void insertUpdate(DocumentEvent e) { doCompletion(); } - public void removeUpdate(DocumentEvent e) { doCompletion(); } - } - - /** This is touchy stuff - so i want to be able to display info about term in - TermInfo when user mouses over terms in combo boxes JList. This is not - explicitly supported by JComboBox. have to dig into its UI to get JList. - The combo box ui selects items in JList on mouse over, this listener - will listen for those mouse over selections - should this be done with a selection event - or is that - overkill, i guess the question will anyone besides term info - ever care about these mouse over selection - if so make generic */ -// void addCompletionListListener(ListSelectionListener lsl) { -// if (!canGetUIJList()) return; -// getUIJList().addListSelectionListener(lsl); } - void enableTermInfoListening(boolean enable) { - if (!canGetUIJList()) - return; - if (enable) - getUIJList().addListSelectionListener(compListListener); - else - getUIJList().removeListSelectionListener(compListListener); - } - - /** this is for MOUSE OVER TERM INFO - changes selection */ - private class CompletionListListener implements ListSelectionListener { - public void valueChanged(ListSelectionEvent e) { - Object source = e.getSource(); - // hate to cast but it is handy here... and it is in fact a JList - if (!(source instanceof JList)) { - System.out.println("source of combo box mouse over event is not JList "+ - source.getClass()); - return; - } - JList jList = (JList)source; - Object selectedValue = jList.getSelectedValue(); - if (selectedValue == null) - return; - //System.out.println("sel val "+selectedValue.getClass()+" name "+selectedValue); - // the selected item should be an OBOClass - if (!(selectedValue instanceof OBOClass)) { - System.out.println("selected completion term is not obo class " - +selectedValue.getClass()); - return; - } - OBOClass oboClass = (OBOClass)selectedValue; - getSelectionManager().selectTerm(AutoComboBox.this,oboClass,getUseTermListener()); - //setTextFromOboClass(oboClass); - } - } // end of CompletionListListener inner class - - private UseTermListener useTermListener; - private UseTermListener getUseTermListener() { - if (useTermListener == null) useTermListener = new ComboUseTermListener(); - return useTermListener; - } - - private class ComboUseTermListener implements UseTermListener { - public void useTerm(UseTermEvent e) { - setOboClass(e.getTerm()); - if (editModel) editModel(); - } - } - - private SelectionManager getSelectionManager() { - return SelectionManager.inst(); - } - - private CharacterI getSelectedCharacter() { - return getSelectionManager().getSelectedCharacter(); - } - - private boolean canGetUIJList() { - return getUIJList() != null; - } - - /** This may return null if not using Metal/Java UI/Look & Feel as JList comes - from the UI - need to implement getting JList from each UI I guess */ - private JList getUIJList() { - ComboBoxUI comboBoxUI = getUI(); - if (!(comboBoxUI instanceof MetalListComboUI)) { - System.out.println("Cant retrieve JList for look & feel, cant do mouse overs " - +comboBoxUI.getClass()); - return null; - } - return ((MetalListComboUI)comboBoxUI).getJList(); - } - - // for TestPhenote - void doMouseOver(int itemNumber) { - //System.out.println("AutoComboBox.doMouseOver not implemented yet"); - if (!canGetUIJList()) return; - JList jList = getUIJList(); - jList.setSelectedIndex(itemNumber); - } - - private class MetalListComboUI extends MetalComboBoxUI { - private JList getJList() { - return listBox; // protected JList in BasicComboBoxUI - } - } - - - - /** Listens for actions from combo boxes and edits model/character - * actions come from mouse select of term as well as return & tab */ - private class ComboBoxActionListener implements ActionListener { - //private OBOClass previousOboClass=null; - - private ComboBoxActionListener() {} - public void actionPerformed(ActionEvent e) { - editCharField(); - } - - /** edits Character field via EditManager. - checks that text in text field from user - is actually an item in completion list, is an obo term. */ - private void editCharField() { - String input = getText(); - if (input == null) return; // probably doesnt happen - // the input should be from selected obo class shouldnt it? is it possible - // for this not to be so? returns null if no oboclass? - // TERM - if (isTermList()) { - try { currentOboClass = getSelectedOboClass(); } - // happens on return on invalid term name - catch (OboException e) { return; } // error msg? - //if (oboClass == null) return; currentOboClass = oboClass; - } - // RELATIONSHIP - else { - try { currentRel = getSelectedRelation(); } - catch (OboException e) { return; } - } - - // EDIT MODEL - if (editModel) - editModel(); - } - } - - private void editModel() { - OBOClass oboClass; - try { oboClass = getCurrentOboClass(); } - catch (Exception e) { return; } // shouldnt happen, error? - if (charField == null) return; // shouldnt happen - CharacterI c = getSelectedCharacter(); // from selectionManager - CharFieldEnum cfe = charField.getCharFieldEnum(); - // isDifferentia boolean? - UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); - EditManager.inst().updateModel(this,ut); - } - - private Logger log; - private Logger log() { - if (log == null) log = Logger.getLogger(getClass()); - return log; - } -} - -class OboException extends Exception { - private OboException() { super(); } - private OboException(String s) { super(s); } -} - -// GARBAGE -// CharacterI c = getSelectedCharacter(); // from selectionManager -// CharFieldEnum cfe = charField.getCharFieldEnum(); -// UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); -// EditManager.inst().updateModel(this,ut); - //private Ontology getOntology() { return ontology; } - - /** Return true if input String matches name of OBOClass in - * defaultComboBoxModel - rename this? this isnt used anymore - delete? - */ -// boolean isInCompletionList(String input) { -// if (defaultComboBoxModel == null) -// return false; -// if (input == null) { -// return false; -// } -// // this is wrong as it holds OBOClasses not Strings! -// //return defaultComboBoxModel.getIndexOf(input) != -1; -// // have to go through all OBOClasses and extract there names - bummer -// // most likely input is selected one check that first -// OBOClass selectedClass = getSelectedOboClass(); -// if (selectedClass != null && input.equals(selectedClass.getName())) -// return true; -// // selected failed(is this possible?) - try everything in the list then... -// for (int i=0; i<defaultComboBoxModel.getSize(); i++) { -// if (input.equals(getCompListOboClass(i).getName())) -// return true; -// } -// return false; -// } - - // mac bug workaround where list covers up textfield on < 12 items no scroll - // from http://www.orbital-computer.de/JComboBox/#usage - // it does note this may cause class cast excpetions?? - // it does cause exception when down arror is typed... hmmm... - //setUI(new BasicComboBoxUI()); // now setting metal look & feel for whole app -//String ontology,AutoComboBox cb) { - //private String previousModelValue=null; - //this.ontology = ontology; - //comboBox = cb; - //setTableFromField(ontology); - //t.editModel(); // or charField.editModel? - // CharacterChangeEvent e = new CharacterChangeEvent(t); - // OR CharEditManager.inst().updateModel(c,cfe,input,previousModelValue); - // CEM.handleTransaction(new UT), CEM.updateModel(UT) - // fireChangeEvent(e); - - // check if input is a real term - i think we can get away with checking - // if in present term completion list - not sure - // i think this is replaced by check above - make sure does the same... -// boolean valid = isInCompletionList(oboClass); //input); -// if (!valid) -// return; - - -// doesnt work - would need to subclass editor component i thing - hassle -// // for TestPhenote -// void simulateBackspace() { -// KeyEvent ke = new KeyEvent(this,KeyEvent.VK_DELETE,java.util.Calendar.getInstance().getTimeInMillis(),0,KeyEvent.VK_UNDEFINED,KeyEvent.CHAR_UNDEFINED); -// //patoComboBox.processKeyEvent(ke); -// getEditor().getEditorComponent().processKeyEvent(ke); - -// } -// Document d = e.getDocument(); -// String input; -// try { -// input = d.getText(0,d.getLength()); -// } -// catch (javax.swing.text.BadLocationException ex) { -// System.out.println(ex); -// return; -// } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |