/*******************************************************************************
 * OpenCPS is the open source Core Public Services software
 * Copyright (C) 2016-present OpenCPS community
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *******************************************************************************/

package org.opencps.dossiermgt.service.impl;

import java.util.Date;

import org.opencps.dossiermgt.model.DossierFile;
import org.opencps.dossiermgt.service.base.DossierFileLocalServiceBaseImpl;

import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.service.ServiceContext;

/**
 * The implementation of the dossier file local service. <p> All custom service
 * methods should be put in this class. Whenever methods are added, rerun
 * ServiceBuilder to copy their definitions into the
 * {@link org.opencps.dossiermgt.service.DossierFileLocalService} interface. <p>
 * This is a local service. Methods of this service will not have security
 * checks based on the propagated JAAS credentials because this service can only
 * be accessed from within the same VM. </p>
 *
 * @author trungnt
 * @see org.opencps.dossiermgt.service.base.DossierFileLocalServiceBaseImpl
 * @see org.opencps.dossiermgt.service.DossierFileLocalServiceUtil
 */
public class DossierFileLocalServiceImpl
    extends DossierFileLocalServiceBaseImpl {
	/*
	 * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use
	 * {@link org.opencps.dossiermgt.service.DossierFileLocalServiceUtil} to
	 * access the dossier file local service.
	 */

	public DossierFile addDossierFile(
	    long userId, long dossierId, long dossierPartId, String templateFileNo,
	    long groupFileId, long ownerUserId, long ownerOrganizationId,
	    String displayName, String formData, long fileEntryId,
	    int dossierFileMark, int dossierFileType, String dossierFileNo,
	    Date dossierFileDate, int original, int syncStatus,
	    ServiceContext serviceContext)
	    throws SystemException {

		long dossierFileId = counterLocalService
		    .increment(DossierFile.class
		        .getName());
		DossierFile dossierFile = dossierFilePersistence
		    .create(dossierFileId);

		Date now = new Date();

		dossierFile
		    .setUserId(userId);
		dossierFile
		    .setGroupId(serviceContext
		        .getScopeGroupId());
		dossierFile
		    .setCompanyId(serviceContext
		        .getCompanyId());
		dossierFile
		    .setCreateDate(now);
		dossierFile
		    .setModifiedDate(now);
		dossierFile
		    .setDisplayName(displayName);
		dossierFile
		    .setDossierFileDate(dossierFileDate);
		dossierFile
		    .setDossierFileMark(dossierFileMark);
		dossierFile
		    .setDossierFileNo(dossierFileNo);
		dossierFile
		    .setDossierFileType(dossierFileType);
		dossierFile
		    .setDossierId(dossierId);
		dossierFile
		    .setDossierPartId(dossierPartId);
		dossierFile
		    .setFileEntryId(fileEntryId);
		dossierFile
		    .setFormData(formData);
		dossierFile
		    .setGroupFileId(groupFileId);
		dossierFile
		    .setOriginal(original);
		dossierFile
		    .setOwnerOrganizationId(ownerOrganizationId);
		dossierFile.setUuid(PortalUUIDUtil.generate());

		return dossierFilePersistence
		    .update(dossierFile);
	}
}

@@ -983,16 +983,74 @@
 .Date;%0A%0A
+import org.opencps.dossiermgt.NoSuchDossierFileException;%0A
 import o
@@ -1090,16 +1090,16 @@
 erFile;%0A
-
 import o
@@ -2285,16 +2285,311 @@
 .%0A%09 */%0A%0A
+%09/* (non-Javadoc)%0A%09 * @see org.opencps.dossiermgt.service.DossierFileLocalService#addDossierFile(long, long, long, java.lang.String, long, long, long, java.lang.String, java.lang.String, long, int, int, java.lang.String, java.util.Date, int, int, com.liferay.portal.service.ServiceContext)%0A%09 */%0A
 %09public 
@@ -4212,24 +4212,24 @@
 Persistence%0A
-
 %09%09    .updat
@@ -4247,10 +4247,361 @@
 le);%0A%09%7D%0A
+%09%0A%09/**%0A%09 * @param dossierId%0A%09 * @param dossierPartId%0A%09 * @return%0A%09 * @throws NoSuchDossierFileException%0A%09 * @throws SystemException%0A%09 */%0A%09public DossierFile getDossierFileByD_P(long dossierId, long dossierPartId)%0A%09    throws NoSuchDossierFileException, SystemException %7B%0A%0A%09%09return dossierFilePersistence%0A%09%09    .findByD_P(dossierId, dossierPartId);%0A%09%7D%0A
 %7D%0A

Add method getDossierFileByD_P