001    /**
002     * Copyright (c) 2000-2010 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.v4_4_0;
016    
017    import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018    import com.liferay.portal.kernel.upgrade.util.BaseUpgradeColumnImpl;
019    import com.liferay.portal.kernel.upgrade.util.TempUpgradeColumnImpl;
020    import com.liferay.portal.kernel.upgrade.util.UpgradeColumn;
021    import com.liferay.portal.kernel.upgrade.util.UpgradeTable;
022    import com.liferay.portal.kernel.upgrade.util.UpgradeTableFactoryUtil;
023    import com.liferay.portal.upgrade.v4_4_0.util.DLFileEntryTable;
024    import com.liferay.portal.upgrade.v4_4_0.util.DLFileEntryTitleColumnImpl;
025    import com.liferay.portal.upgrade.v4_4_0.util.DLFolderNameColumnImpl;
026    import com.liferay.portal.upgrade.v4_4_0.util.DLFolderTable;
027    
028    import java.util.Set;
029    
030    /**
031     * @author Alexander Chow
032     */
033    public class UpgradeDocumentLibrary extends UpgradeProcess {
034    
035            protected void doUpgrade() throws Exception {
036    
037                    // DLFolder
038    
039                    UpgradeColumn groupIdColumn = new TempUpgradeColumnImpl("groupId");
040    
041                    UpgradeColumn parentFolderIdColumn = new TempUpgradeColumnImpl(
042                            "parentFolderId");
043    
044                    DLFolderNameColumnImpl dlFolderNameColumn = new DLFolderNameColumnImpl(
045                            groupIdColumn, parentFolderIdColumn);
046    
047                    UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
048                            DLFolderTable.TABLE_NAME, DLFolderTable.TABLE_COLUMNS,
049                            groupIdColumn, parentFolderIdColumn, dlFolderNameColumn);
050    
051                    upgradeTable.updateTable();
052    
053                    Set<String> distinctNames = dlFolderNameColumn.getDistintNames();
054    
055                    // DLFileEntry
056    
057                    UpgradeColumn folderIdColumn = new TempUpgradeColumnImpl("folderId");
058    
059                    UpgradeColumn nameColumn = new TempUpgradeColumnImpl("name");
060    
061                    BaseUpgradeColumnImpl dlFileEntryTitleColumn =
062                            new DLFileEntryTitleColumnImpl(
063                                    groupIdColumn, folderIdColumn, nameColumn, distinctNames);
064    
065                    upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
066                            DLFileEntryTable.TABLE_NAME, DLFileEntryTable.TABLE_COLUMNS,
067                            folderIdColumn, nameColumn, dlFileEntryTitleColumn);
068    
069                    upgradeTable.updateTable();
070            }
071    
072    }