1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.upgrade.v4_3_0.util;
16  
17  import com.liferay.portal.kernel.upgrade.util.UpgradeColumn;
18  import com.liferay.portal.kernel.upgrade.util.ValueMapper;
19  import com.liferay.portal.kernel.upgrade.util.ValueMapperFactoryUtil;
20  import com.liferay.portal.upgrade.util.PKUpgradeColumnImpl;
21  
22  import java.sql.Types;
23  
24  /**
25   * <a href="JournalStructurePKUpgradeColumnImpl.java.html"><b><i>View Source</i>
26   * </b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class JournalStructurePKUpgradeColumnImpl extends PKUpgradeColumnImpl {
31  
32      public JournalStructurePKUpgradeColumnImpl(
33          UpgradeColumn companyIdColumn, UpgradeColumn groupIdColumn) {
34  
35          super("id_", new Integer(Types.VARCHAR), false);
36  
37          _companyIdColumn = companyIdColumn;
38          _groupIdColumn = groupIdColumn;
39          _journalStructureIdMapper = ValueMapperFactoryUtil.getValueMapper();
40      }
41  
42      public Object getNewValue(Object oldValue) throws Exception {
43          Object newValue = super.getNewValue(oldValue);
44  
45          String companyId = (String)_companyIdColumn.getOldValue();
46          Long groupId = (Long)_groupIdColumn.getOldValue();
47          String structureId = (String)oldValue;
48  
49          String oldIdValue =
50              "{companyId=" + companyId + ", groupId=" + groupId +
51                  ", structureId=" + structureId + "}";
52  
53          _journalStructureIdMapper.mapValue(oldIdValue, newValue);
54  
55          return newValue;
56      }
57  
58      public ValueMapper getValueMapper() {
59          return _journalStructureIdMapper;
60      }
61  
62      private UpgradeColumn _companyIdColumn;
63      private UpgradeColumn _groupIdColumn;
64      private ValueMapper _journalStructureIdMapper;
65  
66  }