roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1613555 - in /roller/trunk/app/src: main/java/org/apache/roller/weblogger/ main/java/org/apache/roller/weblogger/business/jpa/ main/resources/sql/ test/java/org/apache/roller/weblogger/business/
Date Sat, 26 Jul 2014 03:31:41 GMT
Author: gmazza
Date: Sat Jul 26 03:31:41 2014
New Revision: 1613555

URL: http://svn.apache.org/r1613555
Log:
(Tiny breach of data model freeze) foreign key constraint added to custom_template_rendition's
templateid column, pointing back to the id value in weblog_custom_template.  Some code bugs
popped up as a result (where we were deleting the parent before deleting the children), also
fixed in this commit.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
    roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm
    roller/trunk/app/src/main/resources/sql/createdb.vm
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/CustomTemplateRenditionTest.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java?rev=1613555&r1=1613554&r2=1613555&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java Sat Jul 26 03:31:41
2014
@@ -116,11 +116,9 @@ public final class TestUtils {
      *            true if you want to flush changes to db before releasing
      */
     public static void endSession(boolean flush) throws Exception {
-
         if (flush) {
             WebloggerFactory.getWeblogger().flush();
         }
-
         WebloggerFactory.getWeblogger().release();
     }
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java?rev=1613555&r1=1613554&r2=1613555&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
Sat Jul 26 03:31:41 2014
@@ -247,8 +247,8 @@ public class JPAWeblogManagerImpl implem
     
     public void removeTemplate(WeblogTemplate template) throws WebloggerException {
         //remove template code objects
-       this.removeTemplateRenditions(template);
-
+        this.removeTemplateRenditions(template);
+        this.strategy.flush();
         this.strategy.remove(template);
         // update weblog last modified date.  date updated by saveWeblog()
         roller.getWeblogManager().saveWeblog(template.getWeblog());

Modified: roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm?rev=1613555&r1=1613554&r2=1613555&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm (original)
+++ roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm Sat Jul 26 03:31:41 2014
@@ -4,6 +4,7 @@
 DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!!
 **#
 
+-- website table was renamed to weblog and several unused columns dropped
 #renameTable('website' 'weblog')
 #dropColumn('weblog' 'emailfromaddress')
 #dropColumn('weblog' 'pagemodels')
@@ -12,17 +13,22 @@ DON'T RUN THIS, IT'S NOT A DATABASE CREA
 #dropColumn('weblog' 'defaultpageid')
 #dropColumn('weblog' 'weblogdayid')
 #dropColumn('weblog' 'defaultplugins')
+
+-- two weblog columns renamed
 #addColumnNotNull('weblog' 'visible' $db.BOOLEAN_SQL_TYPE $db.BOOLEAN_TRUE)
 #addColumnNull('weblog' 'tagline'  "varchar(255)")
-
 update weblog set visible = isenabled;
 update weblog set tagline = description;
-
 #dropColumn('weblog' 'isenabled')
 #dropColumn('weblog' 'description')
 
+-- different value for our Xinha editor
+update weblog set editorpage = 'editor-xinha.jsp' where editorpage = 'editor-rte.jsp';
+
+-- some tables renamed
 #renameTable('folder' 'bookmark_folder')
 #renameTable('rolleruser' 'roller_user')
+#renameTable('webpage' 'weblog_custom_template')
 
 create table custom_template_rendition (
     id varchar(48)  not null primary key,
@@ -32,7 +38,8 @@ create table custom_template_rendition (
     #columnNotNullWithDefault('type' 'varchar(16)' 'STANDARD')
 );
 
-#renameTable('webpage' 'weblog_custom_template')
+alter table custom_template_rendition add constraint ctr_templateid_fk
+    foreign key ( templateid ) references weblog_custom_template( id ) $!db.ADDL_FK_PARAMS
;
 
 -- capitalizing column constants as these are now stored as enums in Java.
 update weblog_custom_template set templatelang = upper(templatelang);
@@ -41,18 +48,19 @@ update weblog_custom_template wct set ac
 -- The main stylesheet for a theme has a new action, STYLESHEET.
 update weblog_custom_template wct set action='STYLESHEET' where link is not null and link
= (select customstylesheet from weblog w where w.id = wct.websiteid);
 
+-- With above statement, weblog.customstylesheet no longer needed.
 #dropColumn('weblog' 'customstylesheet')
 
-update weblog set editorpage = 'editor-xinha.jsp' where editorpage = 'editor-rte.jsp';
-
+-- template renditions now stored in custom_template_rendition table; 5.0.x has only standard
(non-mobile) type
 insert into custom_template_rendition(id, templateid, template, templatelang, type)
 select id, id, template, templatelang, 'STANDARD' from weblog_custom_template;
 
+-- With above statement, below columns no longer needed
 #dropColumn('weblog_custom_template' 'template')
 #dropColumn('weblog_custom_template' 'templatelang')
 #dropColumn('weblog_custom_template' 'decorator')
 
-
+-- HTML header search description now available for each blog entry
 #addColumnNull("weblogentry" "search_description"  "varchar(255)")
 
 -- Removal of subcategories means no more path and parentid columns
@@ -90,7 +98,7 @@ update roller_mediafiledir set name = 'd
 -- Adding blog-specific web analytics (e.g. Google Analytics) tracking code
 #addColumnNull("weblog" "analyticscode" $db.TEXT_SQL_TYPE)
 
--- Referer table no longer populated, retaining for older DB's in case legacy data
--- is desired to keep; but removing its FK relationships to other tables
+-- Referer table no longer populated, retaining for older Roller instances in case
+-- legacy data is desired to keep; but removing its FK relationships to other tables
 #dropIndex("referer" "ref_entryid_fk")
 #dropIndex("referer" "ref_websiteid_fk")

Modified: roller/trunk/app/src/main/resources/sql/createdb.vm
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/sql/createdb.vm?rev=1613555&r1=1613554&r2=1613555&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/sql/createdb.vm (original)
+++ roller/trunk/app/src/main/resources/sql/createdb.vm Sat Jul 26 03:31:41 2014
@@ -468,6 +468,9 @@ create table roller_mediafiledir (
 alter table weblog_custom_template add constraint wct_weblogid_fk
     foreign key ( websiteid ) references weblog( id ) $!db.ADDL_FK_PARAMS ;
 
+alter table custom_template_rendition add constraint ctr_templateid_fk
+    foreign key ( templateid ) references weblog_custom_template( id ) $!db.ADDL_FK_PARAMS
;
+
 alter table weblogentry add constraint we_weblogid_fk
     foreign key ( websiteid ) references weblog( id ) $!db.ADDL_FK_PARAMS ;
 

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/CustomTemplateRenditionTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/CustomTemplateRenditionTest.java?rev=1613555&r1=1613554&r2=1613555&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/CustomTemplateRenditionTest.java
(original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/CustomTemplateRenditionTest.java
Sat Jul 26 03:31:41 2014
@@ -97,34 +97,31 @@ public class CustomTemplateRenditionTest
         * Test basic persistence operations ... Create, Update, Delete
         */
        public void testTemplateCRUD() throws Exception {
-
            WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
 
-
            // create template
            mgr.saveTemplate(testPage);
+           TestUtils.endSession(true);
 
-
-           //create standard template coce
+           //create standard template rendition
            CustomTemplateRendition standardTemplateCode = new CustomTemplateRendition(testPage.getId(),
RenditionType.STANDARD);
            standardTemplateCode.setTemplate("standard.template.code");
            standardTemplateCode.setTemplateLanguage(TemplateLanguage.VELOCITY);
            mgr.saveTemplateRendition(standardTemplateCode);
-            //TestUtils.endSession(true);
+
            //create mobile code
            CustomTemplateRendition mobileTemplateCode = new CustomTemplateRendition(testPage.getId(),
RenditionType.MOBILE);
            mobileTemplateCode.setTemplate("mobile.template.code");
            mobileTemplateCode.setTemplateLanguage(TemplateLanguage.VELOCITY);
            mgr.saveTemplateRendition(mobileTemplateCode);
-             TestUtils.endSession(true);
-
+           TestUtils.endSession(true);
 
            // check that create was successful
-            standardCode = mgr.getTemplateRenditionByType(testPage.getId(), RenditionType.STANDARD);
+           standardCode = mgr.getTemplateRenditionByType(testPage.getId(), RenditionType.STANDARD);
            assertNotNull(standardCode);
            assertEquals(standardTemplateCode.getTemplate() ,standardCode.getTemplate());
 
-            mobileCode = mgr.getTemplateRenditionByType(testPage.getId(), RenditionType.MOBILE);
+           mobileCode = mgr.getTemplateRenditionByType(testPage.getId(), RenditionType.MOBILE);
            assertNotNull(mobileCode);
            assertEquals(mobileTemplateCode.getTemplate() ,mobileCode.getTemplate());
 



Mime
View raw message