[myblog] r428 committed - refactor the springmvc branch.

1 view
Skip to first unread message

myb...@googlecode.com

unread,
May 13, 2011, 12:51:14 PM5/13/11
to mybl...@googlegroups.com
Revision: 428
Author: Ror...@gmail.com
Date: Fri May 13 09:50:09 2011
Log: refactor the springmvc branch.
http://code.google.com/p/myblog/source/detail?r=428

Added:
/branches/myblog2-springmvc/myblog-core
/branches/myblog2-springmvc/myblog-core/pom.xml
/branches/myblog2-springmvc/myblog-core/src
/branches/myblog2-springmvc/myblog-core/src/main
/branches/myblog2-springmvc/myblog-core/src/main/java
/branches/myblog2-springmvc/myblog-core/src/main/java/com
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/Constants.java

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/domain

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

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/exception

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/exception/DuplicateException.java

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/hibernate

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/hibernate/Condition.java

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/hibernate/StringListType.java
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util/PaginationSupport.java

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util/Range.java

/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util/Sorter.java
/branches/myblog2-springmvc/myblog-core/src/test
/branches/myblog2-springmvc/myblog-core/src/test/java
/branches/myblog2-springmvc/myblog-core/src/test/java/com
/branches/myblog2-springmvc/myblog-core/src/test/java/com/jdkcn
/branches/myblog2-springmvc/myblog-core/src/test/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-core/src/test/java/com/jdkcn/myblog/SorterTest.java
/branches/myblog2-springmvc/myblog-domain
/branches/myblog2-springmvc/myblog-domain/pom.xml
/branches/myblog2-springmvc/myblog-domain/src
/branches/myblog2-springmvc/myblog-domain/src/main
/branches/myblog2-springmvc/myblog-domain/src/main/java
/branches/myblog2-springmvc/myblog-domain/src/main/java/com
/branches/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn
/branches/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain

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

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

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

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

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

/branches/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/User.java
/branches/myblog2-springmvc/myblog-domain/src/test
/branches/myblog2-springmvc/myblog-domain/src/test/java
/branches/myblog2-springmvc/myblog-domain/src/test/java/com
/branches/myblog2-springmvc/myblog-domain/src/test/java/com/jdkcn
/branches/myblog2-springmvc/myblog-domain/src/test/java/com/jdkcn/myblog
/branches/myblog2-springmvc/myblog-service
/branches/myblog2-springmvc/myblog-service/pom.xml
/branches/myblog2-springmvc/myblog-service/src
/branches/myblog2-springmvc/myblog-service/src/main
/branches/myblog2-springmvc/myblog-service/src/main/java
/branches/myblog2-springmvc/myblog-service/src/main/java/com
/branches/myblog2-springmvc/myblog-service/src/main/java/com/jdkcn
/branches/myblog2-springmvc/myblog-service/src/main/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-service/src/main/java/com/jdkcn/myblog/App.java
/branches/myblog2-springmvc/myblog-service/src/test
/branches/myblog2-springmvc/myblog-service/src/test/java
/branches/myblog2-springmvc/myblog-service/src/test/java/com
/branches/myblog2-springmvc/myblog-service/src/test/java/com/jdkcn
/branches/myblog2-springmvc/myblog-service/src/test/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-service/src/test/java/com/jdkcn/myblog/AppTest.java
/branches/myblog2-springmvc/myblog-web
/branches/myblog2-springmvc/myblog-web/pom.xml
/branches/myblog2-springmvc/myblog-web/src
/branches/myblog2-springmvc/myblog-web/src/main
/branches/myblog2-springmvc/myblog-web/src/main/java
/branches/myblog2-springmvc/myblog-web/src/main/java/com
/branches/myblog2-springmvc/myblog-web/src/main/java/com/jdkcn
/branches/myblog2-springmvc/myblog-web/src/main/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-web/src/main/java/com/jdkcn/myblog/App.java
/branches/myblog2-springmvc/myblog-web/src/test
/branches/myblog2-springmvc/myblog-web/src/test/java
/branches/myblog2-springmvc/myblog-web/src/test/java/com
/branches/myblog2-springmvc/myblog-web/src/test/java/com/jdkcn
/branches/myblog2-springmvc/myblog-web/src/test/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-web/src/test/java/com/jdkcn/myblog/AppTest.java
/branches/myblog2-springmvc/myblog-webapp
/branches/myblog2-springmvc/myblog-webapp/pom.xml
/branches/myblog2-springmvc/myblog-webapp/src
/branches/myblog2-springmvc/myblog-webapp/src/main
/branches/myblog2-springmvc/myblog-webapp/src/main/java
/branches/myblog2-springmvc/myblog-webapp/src/main/java/com
/branches/myblog2-springmvc/myblog-webapp/src/main/java/com/jdkcn
/branches/myblog2-springmvc/myblog-webapp/src/main/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-webapp/src/main/java/com/jdkcn/myblog/App.java
/branches/myblog2-springmvc/myblog-webapp/src/test
/branches/myblog2-springmvc/myblog-webapp/src/test/java
/branches/myblog2-springmvc/myblog-webapp/src/test/java/com
/branches/myblog2-springmvc/myblog-webapp/src/test/java/com/jdkcn
/branches/myblog2-springmvc/myblog-webapp/src/test/java/com/jdkcn/myblog

/branches/myblog2-springmvc/myblog-webapp/src/test/java/com/jdkcn/myblog/AppTest.java
Modified:
/branches/myblog2-springmvc/pom.xml

=======================================
--- /dev/null
+++ /branches/myblog2-springmvc/myblog-core/pom.xml Fri May 13 09:50:09 2011
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>myblog</artifactId>
+ <groupId>com.jdkcn.myblog</groupId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>com.jdkcn.myblog</groupId>
+ <artifactId>myblog-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>myblog-core</name>
+ <url>http://code.google.com/p/myblog</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/Constants.java
Fri May 13 09:50:09 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/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/domain/BaseDomain.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,64 @@
+/**
+ * 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 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/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/exception/DuplicateException.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,79 @@
+/**
+ * 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.exception;
+
+import org.apache.commons.lang.exception.NestableRuntimeException;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+public class DuplicateException extends NestableRuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7923812903904409142L;
+
+ public DuplicateException(String type, String name, Object value) {
+ super("The [" + type + "] has duplicate with [" + name + ":" + value
+ "]");
+ }
+
+ /**
+ *
+ */
+ public DuplicateException() {
+ super();
+ }
+
+ /**
+ * @param msg
+ * @param cause
+ */
+ public DuplicateException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ /**
+ * @param msg
+ */
+ public DuplicateException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * @param cause
+ */
+ public DuplicateException(Throwable cause) {
+ super(cause);
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/hibernate/Condition.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,59 @@
+/**
+ * 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.hibernate;
+
+import javax.persistence.Query;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+public interface Condition {
+
+ /**
+ * Decorate a hql by the condition.
+ *
+ * @return the hql
+ */
+ String decorateHql();
+
+ /**
+ * Set the query's parameters.
+ *
+ * @param query
+ */
+ void setParameters(Query query);
+
+ /**
+ * Indeed this condition blank or not.
+ *
+ * @return true if blank, false if not blank
+ */
+ boolean isBlank();
+
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/hibernate/StringListType.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,218 @@
+/**
+ * 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.hibernate;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.ElementCollection;
+
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.type.StandardBasicTypes;
+import org.hibernate.usertype.UserType;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 12, 2010 2:50:11 PM
+ * @version $Id$
+ * @deprecated use {@link ElementCollection} instead
+ */
+@Deprecated
+public class StringListType implements UserType {
+
+ private static final String SPLITTER = "$$$$$";
+
+ private static final int[] TYPES = new int[] { Types.LONGVARCHAR };
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#assemble(java.io.Serializable,
+ * java.lang.Object)
+ */
+ public Object assemble(Serializable cached, Object owner) throws
HibernateException {
+ return cached;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#deepCopy(java.lang.Object)
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public Object deepCopy(Object value) throws HibernateException {
+ if (value == null) {
+ return null;
+ }
+ List sourceList = (List) value;
+ List targetList = new ArrayList();
+ targetList.addAll(sourceList);
+ return targetList;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#disassemble(java.lang.Object)
+ */
+ public Serializable disassemble(Object value) throws
HibernateException {
+ return (Serializable) value;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#equals(java.lang.Object,
+ * java.lang.Object)
+ */
+ @SuppressWarnings("rawtypes")
+ public boolean equals(Object one, Object another) throws
HibernateException {
+ if (one == another)
+ return true;
+ if (one != null && another != null) {
+ List a = (List) one;
+ List b = (List) another;
+ if (a.size() != b.size())
+ return false;
+ for (int i = 0; i < a.size(); i++) {
+ String str1 = (String) a.get(i);
+ String str2 = (String) b.get(i);
+ if (!str1.equals(str2))
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#hashCode(java.lang.Object)
+ */
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#isMutable()
+ */
+ public boolean isMutable() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet,
+ * java.lang.String[], java.lang.Object)
+ */
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
throws HibernateException, SQLException {
+ String value = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
+ if (value != null) {
+ return parse(value);
+ } else {
+ return null;
+ }
+ }
+
+ private Object parse(String value) {
+ String[] strs = StringUtils.split(value, SPLITTER);
+ List<String> quotes = new ArrayList<String>();
+ for (int i = 0; i < strs.length; i++) {
+ quotes.add(strs[i]);
+ }
+ return quotes;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement,
+ * java.lang.Object, int)
+ */
+ @SuppressWarnings({ "rawtypes"})
+ public void nullSafeSet(PreparedStatement pstmt, Object value, int index)
throws HibernateException, SQLException {
+ if (value != null) {
+ String str = disassemble((List) value);
+ StandardBasicTypes.STRING.nullSafeSet(pstmt, str, index);
+ } else {
+ StandardBasicTypes.STRING.nullSafeSet(pstmt, value, index, null);
+ }
+ }
+
+ public String disassemble(@SuppressWarnings("rawtypes") List values)
throws HibernateException {
+ if (values.isEmpty())
+ return "";
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < values.size() - 1; i++) {
+ sb.append(values.get(i)).append(SPLITTER);
+ }
+ sb.append(values.get(values.size() - 1));
+ return sb.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#replace(java.lang.Object,
+ * java.lang.Object, java.lang.Object)
+ */
+ public Object replace(Object original, Object target, Object owner)
throws HibernateException {
+ return original;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#returnedClass()
+ */
+ @SuppressWarnings("rawtypes")
+ public Class returnedClass() {
+ return List.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.hibernate.usertype.UserType#sqlTypes()
+ */
+ public int[] sqlTypes() {
+ return TYPES;
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util/PaginationSupport.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,172 @@
+/**
+ * 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.util;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+public class PaginationSupport<T> {
+
+ // 默认每页显示条数
+ public static final int DEFAULT_PAGE_SIZE = 10;
+
+ // 默认开始记录条数
+ public static final int DEFAULT_START = 0;
+
+ // 默认显示页码最大数
+ public static final int DEFAULT_MAX_INDEX_PAGES = 10;
+
+ // 开始记录条数
+ private int start = 0;
+
+ // 每页显示条数
+ private int pageSize = DEFAULT_PAGE_SIZE;
+
+ // 总记录数
+ private int totalCount;
+
+ // 总页数
+ private int totalPage;
+
+ // 当前页
+ private int currentPage;
+
+ // 返回结果集
+ private List<T> items = new LinkedList<T>();
+
+ public PaginationSupport() {
+ setTotalCount(0);
+ setStart(0);
+ setItems(new LinkedList<T>());
+ }
+
+ public PaginationSupport(List<T> items, int totalCount) {
+ setPageSize(DEFAULT_PAGE_SIZE);
+ setTotalCount(totalCount);
+ setItems(items);
+ setStart(0);
+ }
+
+ public PaginationSupport(List<T> items, int totalCount, int start) {
+ setPageSize(DEFAULT_PAGE_SIZE);
+ setTotalCount(totalCount);
+ setItems(items);
+ setStart(start);
+ }
+
+ public PaginationSupport(List<T> items, int totalCount, int start, int
pageSize) {
+ setPageSize(pageSize);
+ setTotalCount(totalCount);
+ setItems(items);
+ setStart(start);
+ }
+
+ public List<T> getItems() {
+ return items;
+ }
+
+ public void setItems(List<T> items) {
+ if (items == null) {
+ this.items = new LinkedList<T>();
+ } else {
+ this.items = items;
+ }
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(int totalCount) {
+ if (totalCount > 0) {
+ this.totalCount = totalCount;
+ int count = totalCount / pageSize;
+ if (totalCount % pageSize > 0) {
+ count++;
+ }
+ this.totalPage = count;
+ } else {
+ this.totalCount = 0;
+ }
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public void setStart(int start) {
+ if (totalCount <= 0) {
+ this.start = 0;
+ } else if (start >= totalCount) {
+ this.start = totalCount;
+ }else if (start < 0) {
+ this.start = 0;
+ } else {
+ this.start = start;
+ }
+ this.currentPage = start / pageSize + 1;
+ }
+
+ public int getNextIndex() {
+ int nextIndex = getStart() + pageSize;
+ return nextIndex >= totalCount ? getStart() : nextIndex;
+ }
+
+ public int getPreviousIndex() {
+ int previousIndex = getStart() - pageSize;
+ return previousIndex < 0 ? DEFAULT_START : previousIndex;
+ }
+
+ public int getTotalPage() {
+ return totalPage;
+ }
+
+ public void setTotalPage(int totalPage) {
+ this.totalPage = totalPage;
+ }
+
+ public int getCurrentPage() {
+ return currentPage;
+ }
+
+ public void setCurrentPage(int currentPage) {
+ this.currentPage = currentPage;
+ }
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util/Range.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,67 @@
+/**
+ * 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.util;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+public class Range implements Serializable {
+
+ private static final long serialVersionUID = -7773457648929834948L;
+
+ private int start;
+ private int size;
+
+ public Range(int start, int size) {
+ this.start = start;
+ this.size = size;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public void setStart(int start) {
+ this.start = start;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public int getEnd() {
+ return start + size;
+ }
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/main/java/com/jdkcn/myblog/util/Sorter.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,157 @@
+/**
+ * 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.util;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+public class Sorter implements Serializable {
+
+ private static final long serialVersionUID = 757552624922780352L;
+
+ /**
+ * 排序类型
+ */
+ private static enum Type {
+
+ /**
+ * 升序
+ */
+ ASCENDING,
+
+ /**
+ * 降序
+ */
+ DESCENDING
+ }
+
+ /**
+ * 排序指示对象
+ */
+ public static class Sort implements Serializable {
+
+ private static final long serialVersionUID = -1599386645244047497L;
+
+ public String property;
+
+ public Type type;
+
+ /**
+ * 用默认构造器
+ * @param property
+ * @param type
+ */
+ private Sort(String property, Type type) {
+ this.property = property;
+ this.type = type;
+ }
+
+ public boolean isAscending() {
+ return type == Type.ASCENDING;
+ }
+
+ @Override
+ public String toString() {
+ return property + " " + (type ==
Type.ASCENDING ? "asc" : "desc");
+ }
+ }
+
+ private List<Sort> sorts = new ArrayList<Sort>();
+
+ public List<Sort> getSorts() {
+ return sorts;
+ }
+
+ /**
+ * 升序
+ * @param property sort property
+ * @return this
+ */
+ public Sorter asc(String property) {
+ for (Sort sort: sorts) {
+ if (StringUtils.equals(property, sort.property)) {
+ sorts.remove(sort);
+ break;
+ }
+ }
+ sorts.add(new Sort(property, Type.ASCENDING));
+ return this;
+ }
+
+ /**
+ * 降序
+ *
+ * @param property sort property
+ * @return this
+ */
+ public Sorter desc(String property) {
+ for (Sort sort: sorts) {
+ if (StringUtils.equals(property, sort.property)) {
+ sorts.remove(sort);
+ break;
+ }
+ }
+ sorts.add(new Sort(property, Type.DESCENDING));
+ return this;
+ }
+
+
+ /**
+ * 附加order语句到hql上
+ *
+ * @param hql hql
+ * @return decorated hql
+ */
+ public String decorate(String hql) {
+
+ if (sorts.isEmpty()) {
+ return hql;
+ }
+
+ StringBuilder queryBuilder = new StringBuilder(hql);
+ if (StringUtils.containsIgnoreCase(hql, "order by")) {
+ for (Sort sort : sorts) {
+ queryBuilder.append(",").append(sort.toString());
+ }
+ } else {
+ queryBuilder.append(" order by ");
+ for (Sort sort : sorts) {
+ queryBuilder.append(sort.toString()).append(",");
+ }
+ queryBuilder.deleteCharAt(queryBuilder.length() -1);
+ }
+ return queryBuilder.toString();
+ }
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-core/src/test/java/com/jdkcn/myblog/SorterTest.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,58 @@
+/**
+ * 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;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.jdkcn.myblog.util.Sorter;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory</a>
+ * @version $Id$
+ */
+public class SorterTest {
+
+
+ @Test
+ public void testSorter() throws Exception {
+ Sorter sorter = new
Sorter().desc("name").asc("property").desc("createDate");
+ String hql = "from Entry entry";
+ String orderedHql = "from Entry entry order by name desc,property
asc,createDate desc";
+ assertEquals(sorter.decorate(hql), orderedHql);
+ }
+
+ @Test
+ public void testSorterWithExistOrderBy() throws Exception {
+ Sorter sorter = new
Sorter().desc("name").asc("property").desc("createDate");
+ String hql = "from Entry entry order by entry.title desc";
+ String orderedHql = "from Entry entry order by entry.title desc,name
desc,property asc,createDate desc";
+ assertEquals(sorter.decorate(hql), orderedHql);
+ }
+}
=======================================
--- /dev/null
+++ /branches/myblog2-springmvc/myblog-domain/pom.xml Fri May 13 09:50:09
2011
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>myblog</artifactId>
+ <groupId>com.jdkcn.myblog</groupId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>com.jdkcn.myblog</groupId>
+ <artifactId>myblog-domain</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>myblog-domain</name>
+ <url>http://code.google.com/p/myblog</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>myblog-core</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/Blog.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,116 @@
+/**
+ * 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;
+
+import com.jdkcn.myblog.Constants;
+
+/**
+ * @author <a href="mailto:ror...@gmail.com">Rory, Ye</a>
+ * @since May 12, 2010 3:28:42 PM
+ * @version $Id$
+ */
+@Entity
+@Table(name = BaseDomain.TABLE_PREFIX + "blog")
+public class Blog extends BaseDomain {
+
+ private static final long serialVersionUID = 4478429581908619887L;
+
+ private String name;
+
+ private String description;
+
+ private String url;
+
+ private Integer defaultPageSize = Constants.DEFAULT_PAGE_SIZE;
+
+ private String theme;
+
+ private User owner;
+
+ @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;
+ }
+
+ @Column(name = "url", length = 255)
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @Column(name = "description", length = 2048)
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
=======================================
--- /dev/null
+++
/branches/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/Category.java
Fri May 13 09:50:09 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/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/Comment.java
Fri May 13 09:50:09 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/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/Entry.java
Fri May 13 09:50:09 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/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/Tag.java
Fri May 13 09:50:09 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/myblog2-springmvc/myblog-domain/src/main/java/com/jdkcn/myblog/domain/User.java
Fri May 13 09:50:09 2011
@@ -0,0 +1,101 @@
+/**
+ * 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 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 openid;
+
+ private String displayName;
+
+ @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 = "openid", length = 255)
+ public String getOpenid() {
+ return openid;
+ }
+
+ public void setOpenid(String openid) {
+ this.openid = openid;
+ }
+
+ @Column(name = "display_name", length = 200)
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+
+}
=======================================
--- /dev/null
+++ /branches/myblog2-springmvc/myblog-service/pom.xml Fri May 13 09:50:09
2011
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>myblog</artifactId>
+ <groupId>com.jdkcn.myblog</groupId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>com.jdkcn.myblog</groupId>
+ <artifactId>myblog-service</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>myblog-service</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
=======================================
***Additional files exist in this changeset.***
Reply all
Reply to author
Forward
0 new messages