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.dynamicdatalists.asset;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portlet.asset.model.BaseDDMFieldReader;
019    import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
020    import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
021    import com.liferay.portlet.dynamicdatamapping.storage.DDMFormValues;
022    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
023    import com.liferay.portlet.dynamicdatamapping.util.DDMFormValuesToFieldsConverterUtil;
024    
025    /**
026     * @author Adolfo P??rez
027     */
028    public class DDLRecordDDMFieldReader extends BaseDDMFieldReader {
029    
030            public DDLRecordDDMFieldReader(DDLRecord ddlRecord) {
031                    _ddlRecord = ddlRecord;
032            }
033    
034            @Override
035            public Fields getFields() throws PortalException {
036                    DDLRecordSet ddlRecordSet = _ddlRecord.getRecordSet();
037    
038                    DDMFormValues ddmFormValues = _ddlRecord.getDDMFormValues();
039    
040                    return DDMFormValuesToFieldsConverterUtil.convert(
041                            ddlRecordSet.getDDMStructure(), ddmFormValues);
042            }
043    
044            private final DDLRecord _ddlRecord;
045    
046    }