001
014
015 package com.liferay.portlet.dynamicdatalists.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
020 import com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalServiceUtil;
021 import com.liferay.portlet.dynamicdatamapping.NoSuchTemplateException;
022 import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
023 import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
024 import com.liferay.portlet.dynamicdatamapping.service.DDMStructureLocalServiceUtil;
025 import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLocalServiceUtil;
026 import com.liferay.portlet.dynamicdatamapping.storage.Fields;
027
028 import java.util.ArrayList;
029 import java.util.List;
030
031
034 public class DDLRecordSetImpl extends DDLRecordSetBaseImpl {
035
036 public DDLRecordSetImpl() {
037 }
038
039 public DDMStructure getDDMStructure()
040 throws PortalException, SystemException {
041
042 return DDMStructureLocalServiceUtil.getStructure(getDDMStructureId());
043 }
044
045 public DDMStructure getDDMStructure(long formDDMTemplateId)
046 throws PortalException, SystemException {
047
048 DDMStructure ddmStructure = getDDMStructure();
049
050 if (formDDMTemplateId > 0) {
051 try {
052 DDMTemplate ddmTemplate =
053 DDMTemplateLocalServiceUtil.getTemplate(formDDMTemplateId);
054
055
056
057 ddmStructure = (DDMStructure)ddmStructure.clone();
058
059 ddmStructure.setXsd(ddmTemplate.getScript());
060 }
061 catch (NoSuchTemplateException nste) {
062 }
063 }
064
065 return ddmStructure;
066 }
067
068 public List<DDLRecord> getRecords() throws SystemException {
069 return DDLRecordLocalServiceUtil.getRecords(getRecordSetId());
070 }
071
072 public List<Fields> getRecordsFieldsList()
073 throws PortalException, SystemException {
074
075 List<Fields> fieldsList = new ArrayList<Fields>();
076
077 for (DDLRecord record : getRecords()) {
078 fieldsList.add(record.getFields());
079 }
080
081 return fieldsList;
082 }
083
084 }