| ShoppingCouponLimitCategoriesUpgradeColumnImpl.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.portal.upgrade.v4_3_0.util;
16
17 import com.liferay.portal.kernel.upgrade.util.BaseUpgradeColumnImpl;
18 import com.liferay.portal.kernel.upgrade.util.ValueMapper;
19 import com.liferay.portal.kernel.util.GetterUtil;
20 import com.liferay.portal.kernel.util.StringUtil;
21
22 /**
23 * <a href="ShoppingCouponLimitCategoriesUpgradeColumnImpl.java.html"><b><i>View
24 * Source</i></b></a>
25 *
26 * @author Brian Wing Shun Chan
27 */
28 public class ShoppingCouponLimitCategoriesUpgradeColumnImpl
29 extends BaseUpgradeColumnImpl {
30
31 public ShoppingCouponLimitCategoriesUpgradeColumnImpl(
32 ValueMapper shoppingCategoryIdMapper) {
33
34 super("limitCategories");
35
36 _shoppingCategoryIdMapper = shoppingCategoryIdMapper;
37 }
38
39 public Object getNewValue(Object oldValue) throws Exception {
40 String[] limitCategories = StringUtil.split((String)oldValue);
41
42 for (int i = 0; i < limitCategories.length; i++) {
43 limitCategories[i] = String.valueOf(
44 _shoppingCategoryIdMapper.getNewValue(
45 new Long(GetterUtil.getLong(limitCategories[i]))));
46 }
47
48 return StringUtil.merge(limitCategories);
49 }
50
51 private ValueMapper _shoppingCategoryIdMapper;
52
53 }