public void mergeUauthors(String userid, String aid1, String aid2) throws DataAccessException { // dont do antyhing if it's the same aid if ((aid1 == null) || (aid2 == null) || aid1.equals(aid2)) return; UniqueAuthor uauth1 = uauthDAO.getAuthor(aid1); UniqueAuthor uauth2 = uauthDAO.getAuthor(aid2); // dont do anything if one of aid is invalid... if ((uauth1 == null) || (uauth2 == null)) return; // start backing up int version = getMaxVersion.run(aid1) + 1; KeyHolder key = backupUauthor.removePapers(userid, uauth2, version, CSXConstants.USER_VERSION); int update_id = key.getKey().intValue(); // get list of authors record affected... List<Integer> authors = uauthDAO.getAuthorRecords(aid2); for (Integer author_id : authors) { backupAuthors.changeAuthors(update_id, author_id); } // done backing up.. // move papers to uauth1 uauthDAO.moveAuthorRecords(aid1, authors); uauthDAO.updateAuthNdocs(aid1); uauthDAO.updateAuthNcites(aid1); uauthDAO.updateAuthNdocs(aid2); }
public void removeUauthorPapers(String userid, String aid, List<Integer> papers) throws DataAccessException { if ((aid == null) || (papers.size() == 0)) return; UniqueAuthor uauth = uauthDAO.getAuthor(aid); if (uauth == null) return; // start backing up int version = getMaxVersion.run(aid) + 1; KeyHolder key = backupUauthor.removePapers(userid, uauth, version, CSXConstants.USER_VERSION); int update_id = key.getKey().intValue(); // get list of authors record affected... List<Integer> authors = uauthDAO.getAuthorRecordsByPapers(aid, papers); for (Integer author_id : authors) { System.out.println("AID:" + author_id); backupAuthors.changeAuthors(update_id, author_id); } // done backing up.. // remove papers... uauthDAO.moveAuthorRecords(Integer.toString(CSXConstants.USER_REMOVED), authors); uauthDAO.updateAuthNdocs(aid); uauthDAO.updateAuthNcites(aid); }