annotate src/main/java/de/mpiwg/gazetteer/utils/DataProvider.java @ 54:a00efd5d9e77

new: adding delete saved table function
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 04 Feb 2016 11:30:46 +0100
parents 7c2e1b14b77d
children 95bf4ac726e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1 package de.mpiwg.gazetteer.utils;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
2
54
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
3 import java.io.IOException;
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
4 import java.sql.SQLException;
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
5 import java.util.ArrayList;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
6 import java.util.Collections;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
7 import java.util.Date;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
8 import java.util.List;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
9
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
10 import org.apache.log4j.Logger;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
11 import org.hibernate.Session;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
12
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
13 import cl.maps.duplex.DuplexKey;
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
14 import de.mpiwg.gazetteer.bo.LGBranch;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
15 import de.mpiwg.gazetteer.bo.LGFile;
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
16 import de.mpiwg.gazetteer.bo.LGFullTextSearchFile;
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
17 import de.mpiwg.gazetteer.bo.LGTopic;
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
18 import de.mpiwg.gazetteer.bo.LGTopicSectionRelation;
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
19 import de.mpiwg.gazetteer.db.DBContents;
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
20 import de.mpiwg.gazetteer.db.DBSection;
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
21 import de.mpiwg.gazetteer.utils.exceptions.NoAuthorizedException;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
22 import de.mpiwg.gazetteer.utils.exceptions.VersioningException;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
23
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
24 public class DataProvider extends AbstractDataProvider{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
25
43
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
26 private static Logger logger = Logger.getLogger(DataProvider.class);
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
27 private static DataProvider instance;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
28
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
29 public static DataProvider getInstance(){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
30 if(instance == null)
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
31 instance = new DataProvider();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
32 return instance;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
33 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
34
34
2e1662afc81c new: add synchronization for files uploaded to LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
35 public static void resetInstance() {
2e1662afc81c new: add synchronization for files uploaded to LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
36 instance = null;
2e1662afc81c new: add synchronization for files uploaded to LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
37 }
2e1662afc81c new: add synchronization for files uploaded to LGDataverse
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 26
diff changeset
38
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
39 public DataProvider(){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
40 logger.info("##### Starting DataProvider #####");
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
41 }
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
42
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
43
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
44
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
45 /* --- branch --- */
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
46
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
47 public LGFile getFile(Long fileId){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
48 return getFileMap().getValuesByOwnKey(fileId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
49 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
50
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
51 public List<LGFile> getAllFiles(Long branchId){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
52 List<LGFile> list = getFileMap().getValuesByAKey(branchId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
53 Collections.sort(list);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
54 Collections.reverse(list);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
55 return list;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
56 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
57
43
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
58 public List<LGTopicSectionRelation> getAllExistingTopicSectionRelation() {
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
59 List<LGTopicSectionRelation> list = new ArrayList<LGTopicSectionRelation>();
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
60 for (LGTopicSectionRelation relation : getTopicSectionRelationMap().values()) {
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
61 list.add(relation);
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
62 }
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
63 return list;
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
64 }
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
65
38
8b7a204fa929 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 37
diff changeset
66 public List<LGBranch> getAllExistingBranches(){
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
67 List<LGBranch> list = new ArrayList<LGBranch>();
37
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
68 for(LGBranch branch : getBranchMap().values()){
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
69 list.add(branch);
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
70 }
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
71 return list;
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
72 }
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
73
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
74 public List<LGBranch> getBranches(Long userId){
ed215307f426 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 34
diff changeset
75 List<LGBranch> list = new ArrayList<LGBranch>();
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
76 for(LGBranch branch : getBranchMap().values()){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
77 if(branch.hasContributor(userId)){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
78 list.add(branch);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
79 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
80 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
81 return list;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
82 }
38
8b7a204fa929 new: show all existing branches in the searching result page of search for sections
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 37
diff changeset
83
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
84
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
85 public LGBranch getBranch(Long branchId){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
86 return getBranchMap().getValuesByOwnKey(branchId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
87 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
88
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
89 public void deleteFile(LGFile file) throws Exception{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
90
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
91 LGBranch branch = getBranch(file.getBranchId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
92
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
93 if(branch == null){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
94 throw new Exception("There is any Branch for " + file);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
95 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
96
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
97 List<LGFile> files = getAllFiles(file.getBranchId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
98
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
99 if(files.size() == 1){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
100 throw new Exception("This file could not be deleted, because it is part of a branch that has only one file. A Branch without files is a inconsistency.");
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
101 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
102
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
103 // if the file is the last version of a branch, we must replace the current file with the penultimate file.
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
104 if(branch.getCurrentLastFileId().equals(file.getId())){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
105 LGFile penultimateFile = getPenultimateFile(files);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
106
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
107 penultimateFile.setLastVersion(true);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
108 branch.setCurrentLastFileId(penultimateFile.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
109
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
110 this.updateBranch(branch);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
111 this.updateFile(penultimateFile);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
112
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
113 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
114
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
115 //deleting file from DB and cache
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
116 int modifiedFiles = DBService.deleteFileFromDB(file.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
117 getFileMap().remove(file.getKey());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
118
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
119 logger.info(modifiedFiles + " items deleted by removing file " + file);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
120 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
121
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
122 private LGFile getPenultimateFile(List<LGFile> files){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
123 LGFile penultimateFile = null;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
124 LGFile lastFile = null;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
125
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
126 for(LGFile file : files){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
127 if(lastFile == null){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
128 lastFile = file;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
129 }else if(penultimateFile == null){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
130 lastFile = (lastFile.getVersion() > file.getVersion()) ? lastFile : file;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
131 penultimateFile = (lastFile.getVersion() < file.getVersion()) ? lastFile : file;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
132 }else{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
133 if(file.getVersion() > lastFile.getVersion()){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
134 penultimateFile = lastFile;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
135 lastFile = file;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
136 }else if(file.getVersion() > penultimateFile.getVersion()){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
137 penultimateFile = file;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
138 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
139 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
140 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
141
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
142 return penultimateFile;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
143 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
144
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
145 public void deleteBranch(LGBranch branch){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
146
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
147 int modifiedFiles = DBService.deleteBranchFromDB(branch.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
148 List<LGFile> fileToDelete = getFileMap().getValuesByAKey(branch.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
149
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
150 for(LGFile file : new ArrayList<LGFile>(fileToDelete)){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
151 getFileMap().remove(file.getKey());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
152 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
153 getBranchMap().remove(branch.getKey());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
154
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
155 logger.info(modifiedFiles + " items deleted by removing branch " + branch.toString());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
156 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
157
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
158 public void updateFile(LGFile file) throws Exception{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
159 if(!file.isPersistent()){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
160 throw new Exception("Trying to update a file that it is not persistent!");
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
161 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
162
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
163 Date date = new Date();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
164 DBService.saveDBEntry(file, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
165 this.getFileMap().put(file.getKey(), file);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
166 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
167
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
168 public void updateBranch(LGBranch branch) throws Exception{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
169 if(!branch.isPersistent()){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
170 throw new Exception("Trying to update a branch that it is not persistent!");
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
171 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
172
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
173 Date date = new Date();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
174 DBService.saveDBEntry(branch, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
175 this.getBranchMap().put(branch.getKey(), branch);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
176 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
177
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
178 public LGFile saveFile(Long branchId, String text, Long userId, Long userPreviousFileId) throws Exception{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
179
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
180
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
181
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
182 Date date = new Date();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
183
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
184 LGBranch branch = getBranchMap().getValuesByOwnKey(branchId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
185
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
186 if(!branch.hasContributor(userId)){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
187 throw new NoAuthorizedException(userId, branchId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
188 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
189
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
190 if(!branch.getCurrentLastFileId().equals(userPreviousFileId)){
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
191 LGFile userPreviousFile = getFileMap().getValuesByOwnKey(userPreviousFileId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
192 LGFile currentLastFile = getFileMap().getValuesByOwnKey(branch.getCurrentLastFileId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
193
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
194 throw new VersioningException(userPreviousFile, currentLastFile);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
195 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
196
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
197 LGFile previousFile = getFileMap().getValuesByOwnKey(branch.getCurrentLastFileId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
198
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
199 LGFile file = new LGFile();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
200 file.setBranchId(branchId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
201 file.setVersion(previousFile.getVersion() + 1);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
202 file.setUserId(userId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
203 file.setContent(text);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
204
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
205 //Saving into DB
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
206 //##################################
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
207 Session session = HibernateUtil.getSessionFactory().getCurrentSession();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
208 session.getTransaction().begin();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
209
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
210
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
211 file.setBranchId(branch.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
212 DBService.saveDBEntry0(session, file, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
213
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
214 previousFile.setLastVersion(false);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
215 DBService.saveDBEntry0(session, previousFile, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
216
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
217 branch.setCurrentLastFileId(file.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
218 DBService.saveDBEntry0(session, branch, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
219
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
220 //Saving physical file in the operating system
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
221 String fileName = FileManager.saveFile(branch, file, date, userId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
222 file.setFileName(fileName);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
223 DBService.saveDBEntry0(session, file, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
224
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
225 session.getTransaction().commit();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
226 //##################################
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
227
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
228
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
229 //Saving into Cache
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
230 getBranchMap().put(branch.getKey(), branch);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
231 getFileMap().put(file.getKey(), file);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
232 getFileMap().put(previousFile.getKey(), previousFile);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
233
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
234 return file;
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
235 }
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
236
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
237 public Long saveNewFile(String text, String label, Long sectionId, Long userId) throws Exception{
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
238
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
239 Date date = new Date();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
240
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
241 LGBranch branch = new LGBranch();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
242 branch.setSectionId(sectionId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
243 branch.setUserId(userId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
244 branch.setLabel(label);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
245 branch.addContributor(userId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
246 branch.loadTransientData();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
247
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
248 LGFile file = new LGFile();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
249 file.setUserId(userId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
250 file.setContent(text);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
251
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
252 //Saving into DB
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
253 //##################################
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
254 Session session = HibernateUtil.getSessionFactory().getCurrentSession();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
255 session.getTransaction().begin();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
256
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
257 DBService.saveDBEntry0(session, branch, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
258 file.setBranchId(branch.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
259
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
260 DBService.saveDBEntry0(session, file, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
261 branch.setCurrentLastFileId(file.getId());
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
262
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
263 //Saving physical file in the operating system
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
264 String fileName = FileManager.saveFile(branch, file, date, userId);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
265 file.setFileName(fileName);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
266 DBService.saveDBEntry0(session, file, date);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
267
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
268 session.getTransaction().commit();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
269 //##################################
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
270
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
271
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
272 //Saving into Cache
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
273 getBranchMap().put(branch.getKey(), branch);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
274 getFileMap().put(file.getKey(), file);
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
275
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
276 return branch.getId();
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
277
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
278 }
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
279
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
280 /* --- end branch --- */
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
281
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
282
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
283
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
284 /* --- full text search --- */
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
285
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
286 public List<LGFullTextSearchFile> getSearchFileList4User(Long userId) {
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
287
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
288 List<LGFullTextSearchFile> list = new ArrayList<LGFullTextSearchFile>();
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
289
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
290 for(LGFullTextSearchFile searchFile : getFullTextSearchFileMap().values()){
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
291 if(searchFile.getUserId() == userId){
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
292 list.add(searchFile);
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
293 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
294 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
295
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
296 return list;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
297 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
298
49
7c2e1b14b77d new: load existing full text searching result into searching table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 48
diff changeset
299
54
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
300
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
301
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
302 public void deleteLGFullTextSearchFile(LGFullTextSearchFile file) throws IOException{
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
303 //deleting file from DB: the record in table FullTextSearchFile
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
304 int modifiedFiles = DBService.deleteFullTextSearchFileFromDB(file.getId());
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
305
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
306 // delete the files from file system (html in ftsearch-data/... and csv in LGMap/datasets/)
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
307 FileManager.deleteFullTextSearchFileCsv(file);
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
308 FileManager.deleteFullTextSearchFileHtml(file);
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
309
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
310 // delete file from cache
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
311 this.getFullTextSearchFileMap().remove(file.getKey());
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
312 logger.debug("deleteLGFullTextSearchFile");
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
313 }
a00efd5d9e77 new: adding delete saved table function
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 49
diff changeset
314
40
35ed4e650a53 bug fixed: full text search when section not found in section_index table. add paginator
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
315 public LGFullTextSearchFile saveLGFullTextSearchFile(List<DBContents> list, Long userId, LGFullTextSearchFile searchFile) throws Exception {
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
316 // save as csv and html file in filesystem, and records in db `FullTextSearchFile
49
7c2e1b14b77d new: load existing full text searching result into searching table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 48
diff changeset
317 // List<DBContents> list is the filteredList of searching result with isRemoved field
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
318
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
319 Date date = new Date();
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
320
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
321 //Saving into DB
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
322 //##################################
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
323 Session session = HibernateUtil.getSessionFactory().getCurrentSession();
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
324 session.getTransaction().begin();
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
325
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
326 DBService.saveDBEntry0(session, searchFile, date);
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
327
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
328 //Saving physical file in the operating system
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
329 FileManager.saveFullTextSearchFileAsCsv(searchFile, userId, list); // save csv file to LGMap's datasets folder
49
7c2e1b14b77d new: load existing full text searching result into searching table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 48
diff changeset
330 FileManager.saveFullTextSearchFileAsHtml(searchFile, userId, list); // save html file to LGMap's datasets folder
7c2e1b14b77d new: load existing full text searching result into searching table
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 48
diff changeset
331
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
332 session.getTransaction().commit();
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
333 //##################################
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
334
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
335 return searchFile;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
336 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
337
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
338 public LGFullTextSearchFile getFullTextSearchFile(Long fileId) {
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
339
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
340 LGFullTextSearchFile file = getFullTextSearchFileMap().getValuesByOwnKey(fileId);
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
341
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
342 return file;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
343 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
344
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
345 /* --- end full text search --- */
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
346
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
347 /* --- topic --- */
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
348
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
349 public List<LGTopic> getTopics(Long userId){
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
350 List<LGTopic> list = new ArrayList<LGTopic>();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
351 for(LGTopic topic : getTopicMap().values()){
48
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
352 /*
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
353 if(topic.hasContributor(userId)){
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
354 list.add(topic);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
355 }
48
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
356 */
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
357
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
358 // add topic into list anyway, without checking the contributor role.
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
359 list.add(topic);
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
360 }
48
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
361
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
362 return list;
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
363 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
364
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
365 public LGTopic getTopic(Long topicId){
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
366 return getTopicMap().getValuesByOwnKey(topicId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
367 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
368
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
369
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
370 public void deleteTopic(LGTopic topic){
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
371
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
372 int modifiedRelation = DBService.deleteTopicFromDB(topic.getId());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
373 getTopicMap().remove(topic.getKey());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
374
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
375 logger.info("removing " + modifiedRelation + " records in topicSectionRelation of topic " + topic.toString());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
376
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
377 this.setTopicSectionRelationMap(null); // clear topicSectionRelationMap cache
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
378
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
379
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
380 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
381
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
382 public void createTopic(String nameEn, String nameCh,String namePinyin, String description, Long userId) {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
383 Date date = new Date();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
384
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
385 LGTopic topic = new LGTopic();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
386 topic.setNameEn(nameEn);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
387 topic.setNameCh(nameCh);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
388 topic.setNamePinyin(namePinyin);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
389 topic.setDescription(description);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
390 topic.setUserId(userId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
391 topic.setContributors("[" + userId.toString() + "]");
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
392
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
393 //Saving into DB
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
394 //##################################
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
395 // For Topic table
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
396 Session session = HibernateUtil.getSessionFactory().getCurrentSession();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
397 session.getTransaction().begin();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
398
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
399 DBService.saveDBEntry0(session, topic, date);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
400
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
401 session.getTransaction().commit();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
402 //##################################
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
403
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
404 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
405
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
406 public void updateTopic(LGTopic topic) throws Exception {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
407 if(!topic.isPersistent()){
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
408 throw new Exception("Trying to update a topic that it is not persistent!");
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
409 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
410
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
411 Date date = new Date();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
412 DBService.saveDBEntry(topic, date);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
413 this.getTopicMap().put(topic.getKey(), topic);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
414
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
415 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
416
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
417
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
418
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
419 public List<DBSection> getAllSectionsInTopic(Long topicId) throws SQLException{
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
420
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
421 List<LGTopicSectionRelation> topicSectionRelationList = getTopicSectionRelationMap().getValuesByAKey(topicId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
422
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
423 // get sections from topicSecionRelation list
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
424 List<DBSection> list = new ArrayList<DBSection>();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
425 for (LGTopicSectionRelation aRelation : topicSectionRelationList) {
43
9dbbbfd474f4 new: 1.existing topic in search result. 2.difference-set of book for topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 41
diff changeset
426 //logger.debug(aRelation.getInfo() );
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
427
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
428 DBSection section = DBService.getSectionWithContent(aRelation.getSectionId());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
429 list.add(section);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
430
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
431 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
432
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
433
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
434 Collections.sort(list);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
435 Collections.reverse(list);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
436 return list;
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
437 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
438
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
439
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
440
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
441
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
442 public void deleteTopicSectionRelation(Long topicId, String bookId) throws Exception{
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
443 // delete record with topicId, bookId in topicSectionRelation
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
444 // this means the sectionId = 0, there is no corresponding section in the book for this topic
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
445
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
446 // TODO
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
447
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
448 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
449
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
450 public void deleteTopicSectionRelation(Long topicId, Long sectionId) throws Exception{
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
451 if (sectionId == 0) {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
452 throw new Exception("sectionId cannot be 0");
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
453 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
454
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
455 DuplexKey<Long, Long> key = new DuplexKey<Long, Long>(topicId, sectionId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
456 LGTopicSectionRelation topicSectionRelation = this.getTopicSectionRelationMap().get(key);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
457
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
458 LGTopic topic = getTopic(topicId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
459
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
460 if(topic == null){
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
461 throw new Exception("There is no topic of " + topicSectionRelation);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
462 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
463
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
464 //deleting topicSectionRelation from DB and cache
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
465 int modifiedRelation = DBService.deleteTopicSectionRelationFromDB(topicSectionRelation.getId());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
466 getTopicSectionRelationMap().remove(topicSectionRelation.getKey());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
467
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
468 logger.info(modifiedRelation + " items deleted by removing topicSectionRelation " + topicSectionRelation.toString());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
469
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
470
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
471 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
472
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
473 public String updateTopicSectionRelation(Long sectionId, Long topicId) throws Exception {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
474 DuplexKey<Long, Long> key = new DuplexKey<Long, Long>(topicId, sectionId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
475 LGTopicSectionRelation topicSectionRelation = this.getTopicSectionRelationMap().get(key);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
476
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
477 if (topicSectionRelation != null) {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
478 // the relation already existed
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
479 // would this possibly need any modification to the existing record in the topicSectionRelation table?
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
480
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
481 return "updated";
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
482
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
483 } else {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
484 createTopicSectionRelation(sectionId, topicId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
485
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
486 return "added";
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
487 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
488
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
489
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
490
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
491 }
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
492
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
493
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
494 public void createTopicSectionRelation(Long sectionId, Long topicId) throws Exception {
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
495
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
496 Date date = new Date();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
497
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
498 LGTopicSectionRelation topicSectionRelation = new LGTopicSectionRelation();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
499 topicSectionRelation.setTopicId(topicId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
500 topicSectionRelation.setSectionId(sectionId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
501
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
502 DBService.getInstance();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
503 DBSection section = DBService.getSectionWithContent(sectionId);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
504 topicSectionRelation.setBookId(section.getBookId());
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
505
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
506 //Saving into DB
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
507 //##################################
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
508 // For Topic table
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
509 Session session = HibernateUtil.getSessionFactory().getCurrentSession();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
510 session.getTransaction().begin();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
511
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
512 DBService.saveDBEntry0(session, topicSectionRelation, date);
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
513
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
514 session.getTransaction().commit();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
515 //##################################
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
516
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
517 // update cache
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
518 this.loadTopicSectionRelations();
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
519
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
520 }
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
521
48
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
522 public Integer getNumberOfSectionInTopic(Long topicId) {
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
523 List<LGTopicSectionRelation> topicSectionRelationList = getTopicSectionRelationMap().getValuesByAKey(topicId);
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
524
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
525 return topicSectionRelationList.size();
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
526 }
13555aff1f88 new: multiple full text searching. topics and tasks improvement.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 43
diff changeset
527
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 38
diff changeset
528
41
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
529
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
530 /* --- end topic --- */
ba9515f22897 new: topic management and adding sections from searching result into topic
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 40
diff changeset
531
0
3e62083dbcbf First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
532 }