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.portlet.documentlibrary.asset;
016    
017    import com.liferay.asset.kernel.model.ClassTypeField;
018    import com.liferay.asset.kernel.model.DDMStructureClassType;
019    import com.liferay.document.library.kernel.model.DLFileEntryType;
020    import com.liferay.document.library.kernel.service.DLFileEntryTypeLocalServiceUtil;
021    import com.liferay.dynamic.data.mapping.kernel.DDMStructure;
022    import com.liferay.portal.kernel.exception.PortalException;
023    
024    import java.util.ArrayList;
025    import java.util.List;
026    
027    /**
028     * @author Adolfo P??rez
029     */
030    public class DLFileEntryClassType extends DDMStructureClassType {
031    
032            public DLFileEntryClassType(
033                    long classTypeId, String classTypeName, String languageId) {
034    
035                    super(classTypeId, classTypeName, languageId);
036            }
037    
038            @Override
039            public List<ClassTypeField> getClassTypeFields() throws PortalException {
040                    List<ClassTypeField> classTypeFields = new ArrayList<>();
041    
042                    DLFileEntryType dlFileEntryType =
043                            DLFileEntryTypeLocalServiceUtil.getDLFileEntryType(
044                                    getClassTypeId());
045    
046                    List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();
047    
048                    for (DDMStructure ddmStructure : ddmStructures) {
049                            classTypeFields.addAll(
050                                    getClassTypeFields(ddmStructure.getStructureId()));
051                    }
052    
053                    return classTypeFields;
054            }
055    
056    }