Convert dataset comments datetime to epoch, fix PUT comments (#743)

This commit is contained in:
Yi (Alan) Wang 2017-09-13 11:35:59 -07:00 committed by GitHub
parent 5127b90ded
commit 4c39b546f9
4 changed files with 15 additions and 10 deletions

View File

@ -21,8 +21,8 @@ public class DatasetComment {
public String authorName; public String authorName;
public String authorUserName; public String authorUserName;
public String authorEmail; public String authorEmail;
public String created; public long created;
public String modified; public long modified;
public String type; public String type;
public Boolean isAuthor; public Boolean isAuthor;
} }

View File

@ -451,6 +451,10 @@ public class Dataset extends Controller {
Map<String, String[]> params = request().body().asFormUrlEncoded(); Map<String, String[]> params = request().body().asFormUrlEncoded();
if (StringUtils.isNotBlank(username)) { if (StringUtils.isNotBlank(username)) {
if (!params.containsKey("id")) {
params.put("id", new String[]{String.valueOf(commentId)});
}
if (DatasetsDAO.postComment(id, params, username)) { if (DatasetsDAO.postComment(id, params, username)) {
result.put("status", "success"); result.put("status", "success");
return ok(result); return ok(result);

View File

@ -13,6 +13,7 @@
*/ */
package dao; package dao;
import java.sql.Timestamp;
import wherehows.models.table.DatasetComment; import wherehows.models.table.DatasetComment;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
@ -34,13 +35,13 @@ public class DatasetCommentRowMapper implements RowMapper<DatasetComment>
public static String USER_NAME_COLUMN = "username"; public static String USER_NAME_COLUMN = "username";
@Override @Override
public DatasetComment mapRow(ResultSet rs, int rowNum) throws SQLException { public DatasetComment mapRow(ResultSet rs, int rowNum) throws SQLException {
int id = rs.getInt(ID_COLUMN); int id = rs.getInt(ID_COLUMN);
int datasetId = rs.getInt(DATASET_ID_COLUMN); int datasetId = rs.getInt(DATASET_ID_COLUMN);
String text = rs.getString(TEXT_COLUMN); String text = rs.getString(TEXT_COLUMN);
String created = rs.getString(CREATED_TIME_COLUMN); Timestamp created = rs.getTimestamp(CREATED_TIME_COLUMN);
String modified = rs.getString(MODIFIED_TIME_COLUMN); Timestamp modified = rs.getTimestamp(MODIFIED_TIME_COLUMN);
String type = rs.getString(COMMENT_TYPE_COLUMN); String type = rs.getString(COMMENT_TYPE_COLUMN);
if (StringUtils.isBlank(type)) if (StringUtils.isBlank(type))
{ {
@ -53,8 +54,8 @@ public class DatasetCommentRowMapper implements RowMapper<DatasetComment>
datasetComment.id = id; datasetComment.id = id;
datasetComment.datasetId = datasetId; datasetComment.datasetId = datasetId;
datasetComment.text = text; datasetComment.text = text;
datasetComment.created = created; datasetComment.created = created.getTime();
datasetComment.modified = modified; datasetComment.modified = modified.getTime();
datasetComment.type = type; datasetComment.type = type;
datasetComment.authorName = authorName; datasetComment.authorName = authorName;
datasetComment.authorEmail = authorEmail; datasetComment.authorEmail = authorEmail;

View File

@ -221,6 +221,9 @@ public class DatasetsDAO extends AbstractMySQLOpenSourceDAO
private final static String CREATE_DATASET_COMMENT = "INSERT INTO comments " + private final static String CREATE_DATASET_COMMENT = "INSERT INTO comments " +
"(text, user_id, dataset_id, created, modified, comment_type) VALUES(?, ?, ?, NOW(), NOW(), ?)"; "(text, user_id, dataset_id, created, modified, comment_type) VALUES(?, ?, ?, NOW(), NOW(), ?)";
private final static String UPDATE_DATASET_COMMENT = "UPDATE comments " +
"SET text = ?, comment_type = ?, modified = NOW() WHERE id = ?";
private final static String GET_WATCHED_URN_ID = "SELECT id FROM watch " + private final static String GET_WATCHED_URN_ID = "SELECT id FROM watch " +
"WHERE user_id = ? and item_type = 'urn' and urn = ?"; "WHERE user_id = ? and item_type = 'urn' and urn = ?";
@ -245,9 +248,6 @@ public class DatasetsDAO extends AbstractMySQLOpenSourceDAO
private final static String CREATE_COLUMN_COMMENT = "INSERT INTO field_comments " + private final static String CREATE_COLUMN_COMMENT = "INSERT INTO field_comments " +
"(comment, user_id, created, modified, comment_crc32_checksum) VALUES(?, ?, NOW(), NOW(), CRC32(?))"; "(comment, user_id, created, modified, comment_crc32_checksum) VALUES(?, ?, NOW(), NOW(), CRC32(?))";
private final static String UPDATE_DATASET_COMMENT = "UPDATE comments " +
"SET text = ?, comment_type = ?, modified = NOW() WHERE id = ?";
private final static String UPDATE_COLUMN_COMMENT = "UPDATE field_comments " + private final static String UPDATE_COLUMN_COMMENT = "UPDATE field_comments " +
"SET comment = ?, modified = NOW() WHERE id = ?"; "SET comment = ?, modified = NOW() WHERE id = ?";