[myblog] r446 committed - make some refactor adding jpa support.

0 views
Skip to first unread message

myb...@googlecode.com

unread,
Jun 14, 2011, 1:34:41 PM6/14/11
to mybl...@googlegroups.com
Revision: 446
Author: Ror...@gmail.com
Date: Tue Jun 14 10:33:56 2011
Log: make some refactor adding jpa support.
http://code.google.com/p/myblog/source/detail?r=446

Added:
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/Constants.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Account.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/BaseDomain.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Category.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Comment.java
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Entry.java
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Tag.java
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/User.java
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/web/validator

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/web/validator/BlogValidator.java
Deleted:

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/service/BlogValidator.java
Modified:
/branches/myblog-springmvc
/branches/myblog-springmvc/pom.xml
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Blog.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/repository/BlogDaoImpl.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/service/BlogManagerImpl.java

/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/web/AddDeleteBlogController.java
/branches/myblog-springmvc/src/main/resources/log4j.properties

=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/Constants.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 13, 2010 10:16:59 PM
+ * @version $Id$
+ */
+public final class Constants {
+
+ private Constants() {
+ }
+
+ /**
+ * The default blog's default page size is {@code 20}
+ */
+ public static final int DEFAULT_PAGE_SIZE = 20;
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Account.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "account")
+public class Account extends BaseDomain {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8987362662125268431L;
+
+ private User user;
+
+ private String loginId;
+
+ private String password;
+
+ @ManyToOne
+ @JoinColumn(name = "user_id")
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ @Column(name = "login_id", length = 100, unique = true, nullable = false)
+ public String getLoginId() {
+ return loginId;
+ }
+
+ public void setLoginId(String loginId) {
+ this.loginId = loginId;
+ }
+
+ @Column(name = "password")
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/BaseDomain.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,37 @@
+package com.jdkcn.myblog.domain;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 1, 2010 1:57:53 PM
+ * @version $Id$
+ */
+@MappedSuperclass
+public abstract class BaseDomain implements Serializable {
+
+ private static final long serialVersionUID = -8439095415977443255L;
+
+ private String id;
+
+ static final String TABLE_PREFIX = "myblog_";
+
+ @Id
+ @GeneratedValue(generator = "system-uuid")
+ @GenericGenerator(name = "system-uuid", strategy = "uuid2")
+ @Column(name = "id", length = 42)
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Category.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,200 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog.domain;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.SortType;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 6, 2010 11:53:13 AM
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "category")
+public class Category extends BaseDomain implements Comparable<Category> {
+
+ private static final long serialVersionUID = 4842815291071953112L;
+
+ private String name;
+
+ private String description;
+
+ private Integer order;
+
+ private Category parent;
+
+ private Set<Category> children = new TreeSet<Category>();
+
+ private Integer count;
+
+ private String slug;
+
+ private Type type;
+
+ private Blog blog;
+
+ @ManyToOne
+ @JoinColumn(name = "blog_id")
+ public Blog getBlog() {
+ return blog;
+ }
+
+ public void setBlog(Blog blog) {
+ this.blog = blog;
+ }
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "type", length = 20, nullable = false)
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public Category(String name) {
+ this.name = name;
+ }
+
+ public Category(String name, Type type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public Category() {
+ }
+
+ @Column(name = "name", nullable = false, length = 50)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Column(name = "description", length = 1024)
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Column(name = "`order`", nullable = false)
+ public Integer getOrder() {
+ return order;
+ }
+
+ public void setOrder(Integer order) {
+ this.order = order;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "parent_id")
+ public Category getParent() {
+ return parent;
+ }
+
+ public void setParent(Category parent) {
+ this.parent = parent;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", fetch =
FetchType.LAZY)
+ @Sort(type = SortType.NATURAL)
+ public Set<Category> getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set<Category> children) {
+ this.children = children;
+ }
+
+ @Column(name = "`count`")
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ @Column(name = "slug", length = 100)
+ public String getSlug() {
+ return slug;
+ }
+
+ public void setSlug(String slug) {
+ this.slug = slug;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Category o) {
+ return getOrder() - o.getOrder();
+ }
+
+ public enum Type {
+ ENTRY("entry"), LINK("link");
+
+ private String code;
+
+ private Type(String code) {
+ this.code = code;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.code;
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Comment.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,179 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog.domain;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "comment")
+public class Comment extends BaseDomain {
+
+ private static final long serialVersionUID = -4565839079868364673L;
+
+ private Entry entry;
+
+ private String content;
+
+ private User author;
+
+ private String authorName;
+
+ private String email;
+
+ private String ip;
+
+ private Date postDate;
+
+ private Date updateDate;
+
+ private Status status;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "status", nullable = false)
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "entry_id")
+ public Entry getEntry() {
+ return entry;
+ }
+
+ public void setEntry(Entry entry) {
+ this.entry = entry;
+ }
+
+ @Column(name = "content", nullable = false)
+ @org.hibernate.annotations.Type(type = "org.hibernate.type.TextType")
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "author_id")
+ public User getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(User author) {
+ this.author = author;
+ }
+
+ @Column(name = "author_name", nullable = false, length = 200)
+ public String getAuthorName() {
+ return authorName;
+ }
+
+ public void setAuthorName(String authorName) {
+ this.authorName = authorName;
+ }
+
+ @Column(name = "email", nullable = false, length = 200)
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ @Column(name = "ip", nullable = false, length = 100)
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "post_date", nullable = false)
+ public Date getPostDate() {
+ return postDate;
+ }
+
+ public void setPostDate(Date postDate) {
+ this.postDate = postDate;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "update_date")
+ public Date getUpdateDate() {
+ return updateDate;
+ }
+
+ public void setUpdateDate(Date updateDate) {
+ this.updateDate = updateDate;
+ }
+
+ public enum Status {
+ PUBLISH("publish"), SPAM("spam"),
WAITING_FOR_APPROVE("waiting_for_approve"), REJECT("reject");
+
+ private String code;
+
+ private Status(String code) {
+ this.code = code;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return code;
+ }
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Entry.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,393 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog.domain;
+
+import java.util.Date;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 1, 2010 10:51:04 PM
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "entry")
+public class Entry extends BaseDomain {
+
+ private static final long serialVersionUID = -2803962521862241671L;
+
+ private String title;
+
+ private String content;
+
+ private String excerpt;
+
+ private String password;
+
+ private String name;
+
+ private Set<Category> categories = new LinkedHashSet<Category>();
+
+ private Type type;
+
+ private User author;
+
+ private Blog blog;
+
+ private Integer commentCount;
+
+ private List<String> pingUrls;
+
+ private List<String> pingedUrls;
+
+ private Date createDate;
+
+ private Date createDateGMT;
+
+ private Date publishDate;
+
+ private Date publishDateGMT;
+
+ private Date updateDate;
+
+ private Date updateDateGMT;
+
+ private Status status;
+
+ private CommentStatus commentStatus;
+
+ private PingStatus pingStatus;
+
+ @Enumerated
+ @Column(name = "comment_status", length = 20, nullable = false)
+ public CommentStatus getCommentStatus() {
+ return commentStatus;
+ }
+
+ public void setCommentStatus(CommentStatus commentStatus) {
+ this.commentStatus = commentStatus;
+ }
+
+ @Enumerated
+ @Column(name = "ping_status", length = 20, nullable = false)
+ public PingStatus getPingStatus() {
+ return pingStatus;
+ }
+
+ public void setPingStatus(PingStatus pingStatus) {
+ this.pingStatus = pingStatus;
+ }
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "status", length = 20, nullable = false)
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "blog_id", nullable = false)
+ public Blog getBlog() {
+ return blog;
+ }
+
+ public void setBlog(Blog blog) {
+ this.blog = blog;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "create_date", nullable = false)
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "create_date_gmt", nullable = false)
+ public Date getCreateDateGMT() {
+ return createDateGMT;
+ }
+
+ public void setCreateDateGMT(Date createDateGMT) {
+ this.createDateGMT = createDateGMT;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "publish_date_gmt")
+ public Date getPublishDateGMT() {
+ return publishDateGMT;
+ }
+
+ public void setPublishDateGMT(Date publishDateGMT) {
+ this.publishDateGMT = publishDateGMT;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "update_date_gmt", nullable = false)
+ public Date getUpdateDateGMT() {
+ return updateDateGMT;
+ }
+
+ public void setUpdateDateGMT(Date updateDateGMT) {
+ this.updateDateGMT = updateDateGMT;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "publish_date")
+ public Date getPublishDate() {
+ return publishDate;
+ }
+
+ public void setPublishDate(Date publishDate) {
+ this.publishDate = publishDate;
+ }
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "update_date", nullable = false)
+ public Date getUpdateDate() {
+ return updateDate;
+ }
+
+ public void setUpdateDate(Date updateDate) {
+ this.updateDate = updateDate;
+ }
+
+ @Column(name = "comment_count")
+ public Integer getCommentCount() {
+ return commentCount;
+ }
+
+ @Column(name = "name", length = 255)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setCommentCount(Integer commentCount) {
+ this.commentCount = commentCount;
+ }
+
+ @ElementCollection(fetch = FetchType.LAZY)
+ @CollectionTable(
+ name = BaseDomain.TABLE_PREFIX + "entry_pingurl",
+ joinColumns = @JoinColumn(name = "entry_id")
+ )
+ @Column(name = "pingurl")
+ public List<String> getPingUrls() {
+ return pingUrls;
+ }
+
+ public void setPingUrls(List<String> pingUrls) {
+ this.pingUrls = pingUrls;
+ }
+
+ @ElementCollection(fetch = FetchType.LAZY)
+ @CollectionTable(
+ name = BaseDomain.TABLE_PREFIX + "entry_pingedurl",
+ joinColumns = @JoinColumn(name = "entry_id")
+ )
+ @Column(name = "pingedurl")
+ public List<String> getPingedUrls() {
+ return pingedUrls;
+ }
+
+ public void setPingedUrls(List<String> pingedUrls) {
+ this.pingedUrls = pingedUrls;
+ }
+
+
+ @Column(name = "password", length = 100)
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "author_id", nullable = false)
+ public User getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(User author) {
+ this.author = author;
+ }
+
+ @Column(name = "title", nullable = false, length = 1024)
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Column(name = "content", nullable = false)
+ @org.hibernate.annotations.Type(type = "org.hibernate.type.TextType")
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ @ManyToMany
+ @JoinTable(name = BaseDomain.TABLE_PREFIX + "entry_category",
joinColumns = @JoinColumn(name = "entry_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "category_id", referencedColumnName
= "id"))
+ public Set<Category> getCategories() {
+ return categories;
+ }
+
+ public void setCategories(Set<Category> categories) {
+ this.categories = categories;
+ }
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "type", length = 20, nullable = false)
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ @Column(name = "excerpt", nullable = false)
+ @org.hibernate.annotations.Type(type = "org.hibernate.type.TextType")
+ public String getExcerpt() {
+ return excerpt;
+ }
+
+ public void setExcerpt(String excerpt) {
+ this.excerpt = excerpt;
+ }
+
+ public enum Status {
+ DRAFT("draft"), PUBLISH("publish");
+
+ private String code;
+
+ private Status(String code) {
+ this.code = code;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.code;
+ }
+ }
+
+ public enum Type {
+ ENTRY("entry"), PAGE("page");
+
+ private String code;
+
+ private Type(String code) {
+ this.code = code;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Enum#toString()
+ */
+ @Override
+ public String toString() {
+ return this.code;
+ }
+ }
+
+ public enum CommentStatus {
+
+ OPEN("open"), CLOSED("closed");
+
+ private String code;
+
+ private CommentStatus(String code) {
+ this.code = code;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.code;
+ }
+ }
+
+ public enum PingStatus {
+
+ OPEN("open"), CLOSED("closed");
+
+ private String code;
+
+ private PingStatus(String code) {
+ this.code = code;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.code;
+ }
+ }
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Tag.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 13, 2010 10:22:34 PM
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "tag")
+public class Tag extends BaseDomain {
+
+ private static final long serialVersionUID = -5041523804059760423L;
+
+ private String name;
+
+ private Integer count;
+
+ @Column(name = "name", length = 50, nullable = false)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Column(name = "`count`")
+ public Integer getCount() {
+ if (count == null) {
+ count = 0;
+ }
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/User.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,105 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jdkcn.myblog.domain;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 12, 2010 2:15:38 PM
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "user")
+public class User extends BaseDomain {
+
+ private static final long serialVersionUID = -3677979703810756329L;
+
+ private String username;
+
+ private String password;
+
+ private String email;
+
+ private String nickname;
+
+ private Set<Account> accounts = new LinkedHashSet<Account>();
+
+ @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "user")
+ public Set<Account> getAccounts() {
+ return accounts;
+ }
+
+ public void setAccounts(Set<Account> accounts) {
+ this.accounts = accounts;
+ }
+
+ @Column(name = "username", length = 100, nullable = false)
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ @Column(name = "password", length = 100, nullable = false)
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Column(name = "email", length = 100, nullable = false)
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ @Column(name = "nickname", length = 200, unique = true)
+ public String getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/web/validator/BlogValidator.java
Tue Jun 14 10:33:56 2011
@@ -0,0 +1,33 @@
+package com.jdkcn.myblog.web.validator;
+
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+
+import com.jdkcn.myblog.domain.Blog;
+
+/**
+ * Validates {@link Blog}.
+ *
+ * @author Jimmy
+ */
+public class BlogValidator implements Validator {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean supports(Class<?> clazz) {
+ return clazz.isAssignableFrom(Blog.class);
+ }
+
+ public void validate(Object obj, Errors errors) {
+ Blog wc = (Blog) obj;
+
+ // if ((wc.getTitle() == null) || (wc.getTitle().length() < 3) ||
(wc.getTitle().length() > 50)) {
+ // errors.rejectValue("title", "err.title", "Title 3-50 characters is
required. *");
+ // }
+ //
+ // if ((wc.getContent() == null) || (wc.getContent().length() < 3) ||
(wc.getContent().length() > 50)) {
+ // errors.rejectValue("content", "err.content", "Content 3-50 characters
is required. *");
+ // }
+ }
+}
=======================================
---
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/service/BlogValidator.java
Wed Jun 1 01:33:04 2011
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.jdkcn.myblog.service;
-
-import org.springframework.validation.Errors;
-import org.springframework.validation.Validator;
-
-import com.jdkcn.myblog.domain.Blog;
-
-
-/**
- * Validates {@link Blog}.
- *
- * @author Jimmy
- */
-public class BlogValidator implements Validator {
- //~ Methods
========================================================================================================
-
- @SuppressWarnings("unchecked")
- public boolean supports(Class clazz) {
- return clazz.equals(Blog.class);
- }
-
- public void validate(Object obj, Errors errors) {
- Blog wc = (Blog) obj;
-
- if ((wc.getTitle() == null) || (wc.getTitle().length() < 3) ||
(wc.getTitle().length() > 50)) {
- errors.rejectValue("title", "err.title", "Title 3-50
characters is required. *");
- }
-
- if ((wc.getContent() == null) || (wc.getContent().length() < 3) ||
(wc.getContent().length() > 50)) {
- errors.rejectValue("content", "err.content", "Content 3-50
characters is required. *");
- }
- }
-}
=======================================
--- /branches/myblog-springmvc/pom.xml Mon Jun 13 11:36:49 2011
+++ /branches/myblog-springmvc/pom.xml Tue Jun 14 10:33:56 2011
@@ -118,61 +118,11 @@

<dependencies>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-expression</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-asm</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.5.RELEASE</version>
@@ -196,12 +146,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
@@ -276,17 +220,6 @@
<artifactId>ehcache</artifactId>
<version>1.6.2</version>
</dependency>
-
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.6.8</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjweaver</artifactId>
- <version>1.6.8</version>
- </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
=======================================
---
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Blog.java
Wed Jun 1 01:33:04 2011
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/domain/Blog.java
Tue Jun 14 10:33:56 2011
@@ -1,58 +1,135 @@
+/**
+ * Copyright (c) 2005-2011, Rory Ye
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
met:
+ *
+ * * Redistributions of source code must retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the Jdkcn.com nor the names of its
contributors may
+ * be used to endorse or promote products derived from this software
without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package com.jdkcn.myblog.domain;

-import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
import javax.persistence.Table;

+import com.jdkcn.myblog.Constants;
+
/**
- *
- * @author Jimmy
- *
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 12, 2010 3:28:42 PM
+ * @version $Id$
*/
-
@Entity
-@Table(name="blog")
-public class Blog implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -591581206254377693L;
-
- private Long id;
- private String title;
- private String content;
-
- //~ Constructors
===================================================================================================
-
- public Blog(String title, String content) {
- this.title = title;
- this.content = content;
- }
-
- public Blog() {}
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getContent() {
- return content;
- }
-
- public void setContent(String content) {
- this.content = content;
+@Table(name = BaseDomain.TABLE_PREFIX + "blog")
+public class Blog extends BaseDomain {
+
+ private static final long serialVersionUID = 4478429581908619887L;
+
+ private String name;
+
+ private String description;
+
+ private List<String> urls;
+
+ private Integer defaultPageSize = Constants.DEFAULT_PAGE_SIZE;
+
+ private String theme;
+
+ private User owner;
+
+ public Blog addUrl(String url) {
+ if (urls == null) {
+ urls = new ArrayList<String>();
+ }
+ urls.add(url);
+ return this;
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "owner_id")
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+
+ @Column(name = "default_page_size")
+ public Integer getDefaultPageSize() {
+ return defaultPageSize;
+ }
+
+ public void setDefaultPageSize(Integer defaultPageSize) {
+ this.defaultPageSize = defaultPageSize;
+ }
+
+ @Column(name = "theme", length = 500)
+ public String getTheme() {
+ return theme;
+ }
+
+ public void setTheme(String theme) {
+ this.theme = theme;
+ }
+
+ @Column(name = "name", nullable = false, length = 255)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @ElementCollection(fetch = FetchType.EAGER)
+ @CollectionTable(
+ name = BaseDomain.TABLE_PREFIX + "blog_url",
+ joinColumns = @JoinColumn(name = "blog_id")
+ )
+ @Column(name = "url")
+ public List<String> getUrls() {
+ return urls;
+ }
+
+ public void setUrls(List<String> urls) {
+ this.urls = urls;
+ }
+
+ @Column(name = "description", length = 2048)
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
}

}
=======================================
---
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/repository/BlogDaoImpl.java
Wed Jun 1 01:33:04 2011
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/repository/BlogDaoImpl.java
Tue Jun 14 10:33:56 2011
@@ -24,9 +24,9 @@
public void create(final Blog blog) {
getJdbcTemplate().update("insert into blogs values (?, ?, ?)", new
PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws
SQLException {
- ps.setLong(1, blog.getId());
- ps.setString(2, blog.getTitle());
- ps.setString(3, blog.getContent());
+// ps.setLong(1, blog.getId());
+// ps.setString(2, blog.getTitle());
+// ps.setString(3, blog.getContent());
}
});
}
@@ -42,9 +42,9 @@
public void update(final Blog blog) {
getJdbcTemplate().update("update blogs set title = ?, content = ?
where id = ?", new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws
SQLException {
- ps.setString(1, blog.getTitle());
- ps.setString(2, blog.getContent());
- ps.setLong(3, blog.getId());
+// ps.setString(1, blog.getTitle());
+// ps.setString(2, blog.getContent());
+// ps.setLong(3, blog.getId());
}
});
}
@@ -85,14 +85,15 @@
}
});
Blog blog = (Blog) list.get(0);
- return blog.getId();
+// return blog.getId();
+ return 0;
}

private Blog mapBlog(ResultSet rs) throws SQLException {
Blog blog = new Blog();
- blog.setId(new Long(rs.getLong("id")));
- blog.setTitle(rs.getString("title"));
- blog.setContent(rs.getString("content"));
+// blog.setId(new Long(rs.getLong("id")));
+// blog.setTitle(rs.getString("title"));
+// blog.setContent(rs.getString("content"));
return blog;
}
}
=======================================
---
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/service/BlogManagerImpl.java
Wed Jun 1 01:33:04 2011
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/service/BlogManagerImpl.java
Tue Jun 14 10:33:56 2011
@@ -64,7 +64,7 @@

public void create(Blog blog) {
// Create the Blog itself
- blog.setId(getLastId()+1);
+// blog.setId(getLastId()+1);
blogDao.create(blog);

// Grant the current principal administrative permission to the
blog
@@ -76,7 +76,7 @@
}

public void delete(Blog blog) {
- blogDao.delete(blog.getId());
+// blogDao.delete(blog.getId());

// Delete the ACL information as well
ObjectIdentity oid = new ObjectIdentityImpl(Blog.class,
blog.getId());
=======================================
---
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/web/AddDeleteBlogController.java
Wed Jun 1 01:33:04 2011
+++
/branches/myblog-springmvc/src/main/java/com/jdkcn/myblog/web/AddDeleteBlogController.java
Tue Jun 14 10:33:56 2011
@@ -13,7 +13,7 @@

import com.jdkcn.myblog.domain.Blog;
import com.jdkcn.myblog.service.BlogManager;
-import com.jdkcn.myblog.service.BlogValidator;
+import com.jdkcn.myblog.web.validator.BlogValidator;

/**
*
@@ -51,7 +51,8 @@
return "add";
}

- Blog blog = new Blog(form.getTitle(), form.getContent());
+// Blog blog = new Blog(form.getTitle(), form.getContent());
+ Blog blog = null;
blogManager.create(blog);

return "redirect:/secure/index.htm";
=======================================
--- /branches/myblog-springmvc/src/main/resources/log4j.properties Wed Jun
1 01:04:00 2011
+++ /branches/myblog-springmvc/src/main/resources/log4j.properties Tue Jun
14 10:33:56 2011
@@ -1,5 +1,5 @@
# Global logging configuration
-log4j.rootLogger=DEBUG, stdout, fileout
+log4j.rootLogger=info, stdout, fileout

log4j.logger.com.myblog=DEBUG
log4j.logger.org.springframework.web.*=DEBUG

Reply all
Reply to author
Forward
0 new messages