# HG changeset patch # User Zoe Hong # Date 1455631780 -3600 # Node ID 95bf4ac726e61c21e274ec2240faee2f3e049bd2 # Parent a00efd5d9e7738ebdc35487a8d8a357d98b3df5c Topic synchronization with extraction-interface. new tables in LGService database diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/java/de/mpiwg/gazetteer/bo/DBEntry.java --- a/src/main/java/de/mpiwg/gazetteer/bo/DBEntry.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/bo/DBEntry.java Tue Feb 16 15:09:40 2016 +0100 @@ -13,6 +13,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.hibernate.annotations.GenericGenerator; + @Entity @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public abstract class DBEntry { @@ -22,7 +24,7 @@ public DBEntry(){} @Id - @GeneratedValue(strategy = GenerationType.TABLE) + @GeneratedValue(strategy = GenerationType.TABLE) @Column(name="id") protected Long id; diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/java/de/mpiwg/gazetteer/bo/LGTopic.java --- a/src/main/java/de/mpiwg/gazetteer/bo/LGTopic.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/bo/LGTopic.java Tue Feb 16 15:09:40 2016 +0100 @@ -49,6 +49,10 @@ @Column(name="keywords") private String keywords; + @Column(name="tag") + private String tag; + + @Transient private List contributorsList; @@ -219,6 +223,17 @@ } + public String getTag() { + return tag; + } + + + public void setTag(String tag) { + this.tag = tag; + } + + + public void setContributorsList(List contributorsList) { this.contributorsList = contributorsList; } @@ -232,7 +247,7 @@ public Integer getNumOfSections() { if (numOfSections == 0){ - // TODO get number of sections in this topic from db table TopicSectionRelation with topicId=this.topicId + // get number of sections in this topic from db table TopicSectionRelation with topicId=this.topicId Long topicId = this.getId(); this.setNumOfSections(DataProvider.getInstance().getNumberOfSectionInTopic(topicId)); diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/java/de/mpiwg/gazetteer/utils/DBService.java --- a/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DBService.java Tue Feb 16 15:09:40 2016 +0100 @@ -976,6 +976,7 @@ Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.getTransaction().begin(); + // delete record in Topic table Query query = session.createQuery("delete LGTopic where id = :id"); query.setLong("id", topicId); modifiedTopic = query.executeUpdate(); @@ -986,6 +987,12 @@ query0.setLong("topicId", topicId); modifiedTopic += query0.executeUpdate(); + // delete records in TopicTagRelation table + Query query1 = session.createQuery("delete LGTopicTagRelation where topicId = :topicId"); + query1.setLong("topicId", topicId); + modifiedTopic += query1.executeUpdate(); + + session.getTransaction().commit(); return modifiedTopic; diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java --- a/src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java Tue Feb 16 15:09:40 2016 +0100 @@ -14,8 +14,10 @@ import de.mpiwg.gazetteer.bo.LGBranch; import de.mpiwg.gazetteer.bo.LGFile; import de.mpiwg.gazetteer.bo.LGFullTextSearchFile; +import de.mpiwg.gazetteer.bo.LGTaglist; import de.mpiwg.gazetteer.bo.LGTopic; import de.mpiwg.gazetteer.bo.LGTopicSectionRelation; +import de.mpiwg.gazetteer.bo.LGTopicTagRelation; import de.mpiwg.gazetteer.db.DBContents; import de.mpiwg.gazetteer.db.DBSection; import de.mpiwg.gazetteer.utils.exceptions.NoAuthorizedException; @@ -372,11 +374,10 @@ int modifiedRelation = DBService.deleteTopicFromDB(topic.getId()); getTopicMap().remove(topic.getKey()); - logger.info("removing " + modifiedRelation + " records in topicSectionRelation of topic " + topic.toString()); + logger.info("removing " + modifiedRelation + " records in TopicSectionRelation and TopicTagRelation table for the topic " + topic.toString()); this.setTopicSectionRelationMap(null); // clear topicSectionRelationMap cache - } public void createTopic(String nameEn, String nameCh,String namePinyin, String description, Long userId) { @@ -390,6 +391,11 @@ topic.setUserId(userId); topic.setContributors("[" + userId.toString() + "]"); + // auto-generating a tag for the topic: could be from nameEn replace space with '_' + String tag = new String(); + tag = nameEn.replace(' ', '_'); + topic.setTag(tag); + //Saving into DB //################################## // For Topic table @@ -398,6 +404,30 @@ DBService.saveDBEntry0(session, topic, date); + // For Taglist table + // create record, which is the topic tag, in taglist table, + // with the taglis.name=nameCh, the taglist.tag=tag, the taglist.color=the defualt topic tag color, which is rgb(255,0,174) + + LGTaglist taglist = new LGTaglist(); + taglist.setName(nameCh); + taglist.setTag(tag); + taglist.setColor("rgb(255, 0, 174)"); + + DBService.saveDBEntry0(session, taglist, date); + + + logger.debug("new topic tag id=" + taglist.getId()); + + + // For TopicTagRelation table + // link the relation between the new topic and its corresponding tag + LGTopicTagRelation relation = new LGTopicTagRelation(); + relation.setTagId(taglist.getId()); + relation.setTopicId(topic.getId()); + + DBService.saveDBEntry0(session, relation, date); + + session.getTransaction().commit(); //################################## diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java --- a/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/web/jsp/FullTextSearchPage.java Tue Feb 16 15:09:40 2016 +0100 @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -68,6 +69,11 @@ private String contentFilter = new String(); private List fileList = null; + private List weekFileList = null; // files modified within the past week + private List monthFileList = null; // files modified within the past month + private List olderFileList = null; // files modified before one month ago + + private String fileName = new String(); private String focusedContentId = new String(); @@ -206,6 +212,36 @@ this.setSelectedContentMessage(this.selectedNumOfContent.toString() + " section(s) selected"); } + + private void dispatchFileListByTime() { + // set this.weekFileList, this.monthFileList, this.olderFileList from this.fileList + this.weekFileList = new ArrayList(); + this.monthFileList = new ArrayList(); + this.olderFileList = new ArrayList(); + + + // TODO + for (LGFullTextSearchFile aFile: this.getFileList()) { + Date todayDate = new Date(); + + long DAY_IN_MS = 1000 * 60 * 60 * 24; + Date oneWeekAgo = new Date(todayDate.getTime() - (7 * DAY_IN_MS)); + Date oneMonthAgo = new Date(todayDate.getTime() - (30 * DAY_IN_MS)); + + if ( aFile.getLastChangeDate().after(oneWeekAgo)) { + this.weekFileList.add(aFile); + + } else if (aFile.getLastChangeDate().after(oneMonthAgo)) { + this.monthFileList.add(aFile); + + } else { + this.olderFileList.add(aFile); + } + + } + + } + public void forceLoadFileList(){ logger.debug("forceLoadFileList"); logger.debug(this.getSearchTerm()); @@ -214,12 +250,19 @@ //logger.debug("userId="+ getSessionBean().getUser().getId()); // set FileList for the user - DataProvider.getInstance().setFullTextSearchFileMap(null); // set fullTextSearchFileMap to null, to force reload - this.setFileList(DataProvider.getInstance().getSearchFileList4User(getSessionBean().getUser().getId())); + this.forceSetFileLists(); + } } + private void forceSetFileLists() { + // set FileList for the user + DataProvider.getInstance().setFullTextSearchFileMap(null); // set fullTextSearchFileMap to null, to force reload + this.setFileList(DataProvider.getInstance().getSearchFileList4User(getSessionBean().getUser().getId())); + this.dispatchFileListByTime(); + } + public void deleteFile() throws IOException { Long fileId = getLongParameter("fileId"); @@ -233,8 +276,7 @@ DataProvider.getInstance().deleteLGFullTextSearchFile(file); // update FileList - DataProvider.getInstance().setFullTextSearchFileMap(null); // set fullTextSearchFileMap to null, to force reload - this.setFileList(DataProvider.getInstance().getSearchFileList4User(getSessionBean().getUser().getId())); + this.forceSetFileLists(); addMsg("The file " + file.getFileName() + " has been deleted."); } @@ -385,9 +427,7 @@ internalError(e); } - // update FileList - DataProvider.getInstance().setFullTextSearchFileMap(null); // set fullTextSearchFileMap to null, to force reload - this.setFileList(DataProvider.getInstance().getSearchFileList4User(getSessionBean().getUser().getId())); + this.forceSetFileLists(); } @@ -777,6 +817,30 @@ + public List getWeekFileList() { + return weekFileList; + } + + public void setWeekFileList(List weekFileList) { + this.weekFileList = weekFileList; + } + + public List getMonthFileList() { + return monthFileList; + } + + public void setMonthFileList(List monthFileList) { + this.monthFileList = monthFileList; + } + + public List getOlderFileList() { + return olderFileList; + } + + public void setOlderFileList(List olderFileList) { + this.olderFileList = olderFileList; + } + public String getMouseX() { return mouseX; } diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/java/de/mpiwg/web/jsp/TopicListPage.java --- a/src/main/java/de/mpiwg/web/jsp/TopicListPage.java Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/java/de/mpiwg/web/jsp/TopicListPage.java Tue Feb 16 15:09:40 2016 +0100 @@ -93,10 +93,9 @@ addMsg("Creating topic Failed. Name(Eng) cannot be empty."); } else if (StringUtils.isEmpty(nameCh)) { addMsg("Creating topic Failed. Name(中文) cannot be empty."); - }else if (StringUtils.isEmpty(namePinyin)) { + } else if (StringUtils.isEmpty(namePinyin)) { addMsg("Creating topic Failed. Name(Pinyin) cannot be empty."); } else { - DataProvider.getInstance().createTopic(nameEn, nameCh, namePinyin, description, userId); addMsg("New topic has been created."); diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/resources/hibernate.cfg.xml --- a/src/main/resources/hibernate.cfg.xml Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/resources/hibernate.cfg.xml Tue Feb 16 15:09:40 2016 +0100 @@ -39,8 +39,10 @@ + - + + diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/webapp/componentes/template.jsp --- a/src/main/webapp/componentes/template.jsp Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/webapp/componentes/template.jsp Tue Feb 16 15:09:40 2016 +0100 @@ -45,7 +45,7 @@ <% if(sessionBean.getUser() == null) { %> - + diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/webapp/pages/fullTextSearch.jsp --- a/src/main/webapp/pages/fullTextSearch.jsp Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/webapp/pages/fullTextSearch.jsp Tue Feb 16 15:09:40 2016 +0100 @@ -49,10 +49,10 @@ var dialogViewSavedResult = $("#dialogViewSavedResult").dialog( { autoOpen: false, - position: { my: "left+100px", at: "top", of: $("#viewSavedResult") }, + //position: { my: "left+100px", at: "top", of: $("#viewSavedResult") }, + position: { my: "center", at: "top+200px", of: $("#viewSavedResult") }, // TODO + width: "850px", - //position: { my: "center", at: "top+150px", of: $("#viewSavedResult") }, // TODO - // width: "600px", } ); $("#viewSavedResult").button().on( "click", function() { @@ -177,44 +177,104 @@ -
+
-
Recent
-
Create AccountCreate Account
+
This week:
+
+ + <% for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getWeekFileList() ){%> + - - - - - + <% } %> + +
+
<%= aFile.getFileName() %>
+ + + - <% for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getFileList() ){%> -
- <%= aFile.getFileName() %> - - - - + + + + + + + + + + + +
+ +
This month:
+ + + <% for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getMonthFileList() ){ %> + - + + <% } %>
+
<%= aFile.getFileName() %>
+ + + - - - - + + + + + + + + + + + + - -
-
Last Week
-
Last Month
Older...
+ + + <% for (LGFullTextSearchFile aFile : sessionBean.getFullTextSearchPage().getOlderFileList() ){%> + + + <% } %> + +
+
<%= aFile.getFileName() %>
+ + + + + + + + + + + + + + + + + +
+ <% for(DBBook book : sessionBean.getTopicPage().getPendingBookList() ) { %> @@ -559,9 +559,10 @@ + + onclick="sectionInExtractionInterface('<%=section.getId() %>', '<%=section.getName() %>', '<%=section.getBookId() %>', '<%=section.getBook().getName() %>', '<%=sessionBean.getTopicPage().getTopicId() %>', '<%=sessionBean.getUser().getId() %>', '<%=sessionBean.getApplicationBean().getExtractionInterfaceUrl()%>');"> diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/webapp/resources/css/style.css --- a/src/main/webapp/resources/css/style.css Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/webapp/resources/css/style.css Tue Feb 16 15:09:40 2016 +0100 @@ -134,13 +134,35 @@ width: 100%; overflow: scroll; overflow-y: hidden; - margin-left: auto; margin-right: auto; border: 3px inset #ABABCC; box-sizing: border-box; } + +.savedResultTable { + background-color: white; + border-collapse: collapse; +} + +.savedResultTable tr { + background:#EBEBEB; +} + +.savedResultTable td { + border-color: inherit; + border-style: solid; + border-width: 1px; + text-align: center; + border-collapse: collapse; + font-size: 12px; + min-width: 60px; + width:60px; +} + + + .pageTable{ width: 100%; background-color: white; diff -r a00efd5d9e77 -r 95bf4ac726e6 src/main/webapp/resources/js/general.js --- a/src/main/webapp/resources/js/general.js Thu Feb 04 11:30:46 2016 +0100 +++ b/src/main/webapp/resources/js/general.js Tue Feb 16 15:09:40 2016 +0100 @@ -6,6 +6,8 @@ bookName, userId, extractionInterfaceUrl){ + // the input parameters contain fileId, since a branch means a text/many version of the text, of a section + var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", extractionInterfaceUrl + "/Extractapp/TaggingText"); // hand to controller @@ -57,7 +59,9 @@ } } -function sectionInExtractionInterface(sectionId, sectionName, bookId, bookName, userId, extractionInterfaceUrl){ +function sectionInExtractionInterface(sectionId, sectionName, bookId, bookName, topicId, userId, extractionInterfaceUrl){ + + // the input parameters contain no fileId, since it's from searching result and haven't assigned topic Or saved var form = document.createElement("form"); form.setAttribute("method", "post"); @@ -89,6 +93,11 @@ hiddenField6.setAttribute("value", bookName); form.appendChild(hiddenField6); + var hiddenField7 = document.createElement("input"); + hiddenField7.setAttribute("name", "topic"); + hiddenField7.setAttribute("value", topicId); + form.appendChild(hiddenField7); + if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.body.appendChild(form); form.submit();