mirror of
https://gh-proxy.org/https://github.com/klinsmaya/VerticleSearchEngine.git
synced 2026-11-08 01:17:13 +08:00
save with Date
This commit is contained in:
@@ -167,7 +167,7 @@ function getUserAuthor(name) {
|
||||
success : function(data) {
|
||||
var list = data.list;
|
||||
for (var i = 0; i < list.length; i ++) {
|
||||
$('#user_author').append('<p>'+list[i]+'</p>');
|
||||
$('#user_author').append('<p>'+list[i].name+' '+list[i].field+''+list[i].date+'</p>');
|
||||
}
|
||||
},
|
||||
error : function(XmlHttpRequest, textStatus, errorThrown) {
|
||||
@@ -184,7 +184,7 @@ function getUserPaper(name) {
|
||||
success : function(data) {
|
||||
var list = data.list;
|
||||
for (var i = 0; i < list.length; i ++) {
|
||||
$('#user_paper').append('<p>'+list[i]+'</p>');
|
||||
$('#user_paper').append('<p>'+list[i].title+' '+list[i].author+' '+list[i].date+'</p>');
|
||||
}
|
||||
},
|
||||
error : function(XmlHttpRequest, textStatus, errorThrown) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dcd.academic.DAO;
|
||||
|
||||
public interface SaveDAO {
|
||||
public void saveAuthor(String username, String author);
|
||||
public void savePaper(String username, String title);
|
||||
public void saveAuthor(String username, String author, String date);
|
||||
public void savePaper(String username, String title, String date);
|
||||
|
||||
public boolean existAuthor(String username, String author);
|
||||
public boolean existPaper(String username, String title);
|
||||
|
||||
@@ -2,12 +2,14 @@ package dcd.academic.DAO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import dcd.academic.model.PublicationModel;
|
||||
import dcd.academic.model.ResearcherModel;
|
||||
import dcd.academic.model.User;
|
||||
|
||||
public interface UserDAO {
|
||||
|
||||
public void addUser(User instance);
|
||||
public ArrayList<String> getUserAuthor(String name);
|
||||
public ArrayList<String> getUserPaper(String name);
|
||||
public ArrayList<ResearcherModel> getUserAuthor(String name);
|
||||
public ArrayList<PublicationModel> getUserPaper(String name);
|
||||
public boolean existUser(String username, String pwd);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class SaveDaoImlp implements SaveDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAuthor(String username, String author) {
|
||||
String query = "insert into UserAuthor(username, author) values(?, ?);";
|
||||
public void saveAuthor(String username, String author, String date) {
|
||||
String query = "insert into UserAuthor(username, author, date) values(?, ?, ?);";
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
|
||||
@@ -52,6 +52,7 @@ public class SaveDaoImlp implements SaveDAO {
|
||||
|
||||
pst.setString(1, username);
|
||||
pst.setString(2, author);
|
||||
pst.setString(3, date);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception e) {
|
||||
System.out.println("#######saveAuthor Exception#######");
|
||||
@@ -65,8 +66,8 @@ public class SaveDaoImlp implements SaveDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePaper(String username, String title) {
|
||||
String query = "insert into UserPaper(username, title) values(?, ?);";
|
||||
public void savePaper(String username, String title, String date) {
|
||||
String query = "insert into UserPaper(username, title, date) values(?, ?, ?);";
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
|
||||
@@ -77,6 +78,7 @@ public class SaveDaoImlp implements SaveDAO {
|
||||
|
||||
pst.setString(1, username);
|
||||
pst.setString(2, title);
|
||||
pst.setString(3, date);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception e) {
|
||||
System.out.println("#######savePaper Exception#######");
|
||||
|
||||
@@ -7,8 +7,11 @@ import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.PreparedStatement;
|
||||
|
||||
import dcd.academic.DAO.UserDAO;
|
||||
import dcd.academic.model.PublicationModel;
|
||||
import dcd.academic.model.ResearcherModel;
|
||||
import dcd.academic.model.User;
|
||||
import dcd.academic.mysql.dbpool.DBConnectionManage;
|
||||
import dcd.academic.solrj.SolrjHelper;
|
||||
|
||||
public class UserDaoImpl implements UserDAO {
|
||||
|
||||
@@ -45,20 +48,25 @@ public class UserDaoImpl implements UserDAO {
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getUserAuthor(String name) {
|
||||
ArrayList<String> authorlist = new ArrayList<String>();
|
||||
String query = "select author from UserAuthor where username=?;";
|
||||
public ArrayList<ResearcherModel> getUserAuthor(String name) {
|
||||
ArrayList<ResearcherModel> authorlist = new ArrayList<ResearcherModel>();
|
||||
String query = "select * from UserAuthor where username=?;";
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
DBConnectionManage dbmanage = DBConnectionManage.getInstance();
|
||||
|
||||
SolrjHelper helper = new SolrjHelper(0);
|
||||
try {
|
||||
con = dbmanage.getFreeConnection();
|
||||
pst = (PreparedStatement) con.prepareStatement(query);
|
||||
pst.setString(1, name);
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
authorlist.add(rs.getString("author").toString());
|
||||
String tmp = rs.getString("author").toString();
|
||||
ResearcherModel model = helper.getAuthorInfo(tmp);
|
||||
model.setDate(rs.getString("date").toString());
|
||||
authorlist.add(model);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -75,20 +83,25 @@ public class UserDaoImpl implements UserDAO {
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getUserPaper(String name) {
|
||||
ArrayList<String> paperlist = new ArrayList<String>();
|
||||
String query = "select title from UserPaper where username=?;";
|
||||
public ArrayList<PublicationModel> getUserPaper(String name) {
|
||||
ArrayList<PublicationModel> paperlist = new ArrayList<PublicationModel>();
|
||||
String query = "select * from UserPaper where username=?;";
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
DBConnectionManage dbmanage = DBConnectionManage.getInstance();
|
||||
|
||||
SolrjHelper helper = new SolrjHelper(1);
|
||||
try {
|
||||
con = dbmanage.getFreeConnection();
|
||||
pst = (PreparedStatement) con.prepareStatement(query);
|
||||
pst.setString(1, name);
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
paperlist.add(rs.getString("title").toString());
|
||||
String tmp = rs.getString("title").toString();
|
||||
PublicationModel model = helper.getPaperInfo(tmp);
|
||||
model.setDate(rs.getString("date").toString());
|
||||
paperlist.add(model);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package dcd.academic.action;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import dcd.academic.DAO.DAOfactory;
|
||||
import dcd.academic.DAO.SaveDAO;
|
||||
import dcd.academic.util.StdOutUtil;
|
||||
|
||||
public class SaveAuthorAction extends ActionSupport {
|
||||
|
||||
@@ -18,7 +20,9 @@ public class SaveAuthorAction extends ActionSupport {
|
||||
DAOfactory factory = new DAOfactory();
|
||||
SaveDAO dao = factory.getSaveDAO();
|
||||
if (!dao.existAuthor(user, author)) {
|
||||
dao.saveAuthor(user, author);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
Date date = cal.getTime();
|
||||
dao.saveAuthor(user, author, date.toLocaleString());
|
||||
type = 1;
|
||||
} else {
|
||||
type = 0;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package dcd.academic.action;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import dcd.academic.DAO.DAOfactory;
|
||||
@@ -18,7 +21,9 @@ public class SavePaperAction extends ActionSupport {
|
||||
DAOfactory factory = new DAOfactory();
|
||||
SaveDAO dao = factory.getSaveDAO();
|
||||
if (!dao.existPaper(user, title)) {
|
||||
dao.savePaper(user, title);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
Date date = cal.getTime();
|
||||
dao.savePaper(user, title, date.toLocaleString());
|
||||
type = 1;
|
||||
} else {
|
||||
type = 0;
|
||||
|
||||
@@ -6,11 +6,12 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import dcd.academic.DAO.UserDAO;
|
||||
import dcd.academic.DAO.impl.UserDaoImpl;
|
||||
import dcd.academic.model.ResearcherModel;
|
||||
|
||||
public class UserAuthorAction extends ActionSupport {
|
||||
private String user;
|
||||
|
||||
public ArrayList<String> list = new ArrayList<String>();
|
||||
public ArrayList<ResearcherModel> list = new ArrayList<ResearcherModel>();
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
@@ -27,13 +28,13 @@ public class UserAuthorAction extends ActionSupport {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public ArrayList<String> getList() {
|
||||
public ArrayList<ResearcherModel> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(ArrayList<String> list) {
|
||||
public void setList(ArrayList<ResearcherModel> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import dcd.academic.DAO.UserDAO;
|
||||
import dcd.academic.DAO.impl.UserDaoImpl;
|
||||
import dcd.academic.model.PublicationModel;
|
||||
|
||||
public class UserPaperAction extends ActionSupport {
|
||||
private String user;
|
||||
|
||||
public ArrayList<String> list = new ArrayList<String>();
|
||||
public ArrayList<PublicationModel> list = new ArrayList<PublicationModel>();
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
@@ -27,11 +28,13 @@ public class UserPaperAction extends ActionSupport {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public ArrayList<String> getList() {
|
||||
public ArrayList<PublicationModel> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(ArrayList<String> list) {
|
||||
public void setList(ArrayList<PublicationModel> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,15 @@ public class PublicationModel {
|
||||
private String pub_abstract = "";
|
||||
private String conference = "";
|
||||
private String view_url = "";
|
||||
private String date = "";
|
||||
private ArrayList<ResearcherModel> authors = new ArrayList<ResearcherModel>();
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
public ArrayList<ResearcherModel> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,15 @@ public class ResearcherModel {
|
||||
private String citations_url = "";
|
||||
private String picurl = "";
|
||||
private String moretags = "";
|
||||
private String date = "";
|
||||
|
||||
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
public String getMoretags() {
|
||||
return moretags;
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ public class SolrjHelper {
|
||||
SolrjClient newclient = new SolrjClient(0);
|
||||
SolrServer server = newclient.getSolrServer();
|
||||
SolrQuery query = new SolrQuery();
|
||||
|
||||
query.setQuery(StringUtil.transformQuery("name", name));
|
||||
query.setStart(0);
|
||||
query.setRows(1);
|
||||
@@ -193,6 +194,7 @@ public class SolrjHelper {
|
||||
author.setHomepage((String)resultDoc.getFieldValue("homepage"));
|
||||
author.setField((String)resultDoc.getFieldValue("field"));
|
||||
author.setPicurl((String)resultDoc.getFieldValue("picurl"));
|
||||
author.setMoretags((String)resultDoc.getFieldValue("moretags"));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -201,6 +203,34 @@ public class SolrjHelper {
|
||||
}
|
||||
return author;
|
||||
}
|
||||
|
||||
|
||||
public PublicationModel getPaperInfo(String title) {
|
||||
PublicationModel paper = null;
|
||||
SolrServer server = client.getSolrServer();
|
||||
SolrQuery query = new SolrQuery();
|
||||
query.setQuery(StringUtil.transformQuery("title", title));
|
||||
query.setStart(0);
|
||||
query.setRows(1);
|
||||
QueryResponse rsp;
|
||||
try {
|
||||
rsp = server.query(query);
|
||||
SolrDocumentList docs = rsp.getResults();
|
||||
Iterator<SolrDocument> it = docs.iterator();
|
||||
while (it.hasNext()) {
|
||||
SolrDocument resultDoc = it.next();
|
||||
paper = new PublicationModel();
|
||||
paper.setAuthor((String)resultDoc.getFieldValue("author"));
|
||||
paper.setConference((String)resultDoc.getFieldValue("conference"));
|
||||
paper.setPub_abstract((String)resultDoc.getFieldValue("pub_abstract"));
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (SolrServerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return paper;
|
||||
}
|
||||
|
||||
public List<String> getAuthorAbstraction(String name, int start, int rows) throws IOException {
|
||||
String s = "";
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,6 +71,9 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
public static String transformQuery(String field, String target) {
|
||||
if (target.contains("(")) {
|
||||
target = target.substring(0, target.indexOf("(")-1);
|
||||
}
|
||||
String[] qs = target.split(" ");
|
||||
String qq = "";
|
||||
for (int i = 0; i < qs.length; i ++) {
|
||||
@@ -80,7 +85,7 @@ public class StringUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
//StdOutUtil.out(qq);
|
||||
|
||||
return qq;
|
||||
}
|
||||
|
||||
@@ -135,6 +140,7 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
StdOutUtil.out(getTokens("is into aaaaa").toString());
|
||||
transformQuery("name", "Deng Cai (蔡登)");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user