001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.upgrade.v6_1_0;
016    
017    import com.liferay.document.library.kernel.model.DLFileEntryTypeConstants;
018    import com.liferay.portal.kernel.upgrade.UpgradeProcess;
019    import com.liferay.portal.kernel.util.LoggingTimer;
020    import com.liferay.portal.kernel.util.PortalUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    
023    /**
024     * @author Alexander Chow
025     */
026    public class UpgradeWorkflow extends UpgradeProcess {
027    
028            @Override
029            protected void doUpgrade() throws Exception {
030                    updateWorkflowDefinitionLinks();
031            }
032    
033            protected void updateWorkflowDefinitionLinks() throws Exception {
034                    try (LoggingTimer loggingTimer = new LoggingTimer()) {
035                            StringBundler sb = new StringBundler(6);
036    
037                            sb.append("update WorkflowDefinitionLink set classNameId = ");
038    
039                            long folderClassNameId = PortalUtil.getClassNameId(
040                                    "com.liferay.portlet.documentlibrary.model.DLFolder");
041    
042                            sb.append(folderClassNameId);
043    
044                            sb.append(", typePK = ");
045                            sb.append(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_ALL);
046                            sb.append(" where classNameId = ");
047    
048                            long fileEntryClassNameId = PortalUtil.getClassNameId(
049                                    "com.liferay.portlet.documentlibrary.model.DLFileEntry");
050    
051                            sb.append(fileEntryClassNameId);
052    
053                            runSQL(sb.toString());
054                    }
055            }
056    
057    }