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.portlet.softwarecatalog.model.impl;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portlet.softwarecatalog.model.SCLicense;
019    import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
020    import com.liferay.portlet.softwarecatalog.model.SCProductScreenshot;
021    import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
022    import com.liferay.portlet.softwarecatalog.service.SCLicenseLocalServiceUtil;
023    import com.liferay.portlet.softwarecatalog.service.SCProductScreenshotLocalServiceUtil;
024    import com.liferay.portlet.softwarecatalog.service.SCProductVersionLocalServiceUtil;
025    
026    import java.util.List;
027    
028    /**
029     * @author Brian Wing Shun Chan
030     */
031    public class SCProductEntryImpl
032            extends SCProductEntryModelImpl implements SCProductEntry {
033    
034            public SCProductEntryImpl() {
035            }
036    
037            public SCProductVersion getLatestVersion() throws SystemException {
038                    List<SCProductVersion> results =
039                            SCProductVersionLocalServiceUtil.getProductVersions(
040                                    getProductEntryId(), 0, 1);
041    
042                    SCProductVersion lastVersion = null;
043    
044                    if (results.size() > 0) {
045                            lastVersion = results.get(0);
046                    }
047    
048                    return lastVersion;
049            }
050    
051            public List<SCLicense> getLicenses() throws SystemException {
052                    return SCLicenseLocalServiceUtil.getProductEntryLicenses(
053                            getProductEntryId());
054            }
055    
056            public List<SCProductScreenshot> getScreenshots() throws SystemException {
057                    return SCProductScreenshotLocalServiceUtil.getProductScreenshots(
058                            getProductEntryId());
059            }
060    
061    }