Mattia Gosetto 4 anni fa
parent
commit
a36d4c2f13
  1. 85
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java
  2. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  3. 2
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp

85
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java

@ -7,6 +7,7 @@ import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Pagamento;
import it.tref.liferay.portos.bo.model.Sorteggio; import it.tref.liferay.portos.bo.model.Sorteggio;
import it.tref.liferay.portos.bo.model.Territorio; import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalService; import it.tref.liferay.portos.bo.service.ConfigurazioneLocalService;
@ -17,6 +18,7 @@ import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalService; import it.tref.liferay.portos.bo.service.DocPraticaLocalService;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil; import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.persistence.DocPraticaPersistenceImpl; import it.tref.liferay.portos.bo.service.persistence.DocPraticaPersistenceImpl;
@ -96,13 +98,21 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException { public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException {
SismicaUtil.sostituisciDL(actionRequest, actionResponse); SismicaUtil.sostituisciDL(actionRequest, actionResponse);
Long userId = null; long userId = 0;
String title = null; String title = null;
String description = null; String description = null;
String mimeType = null; String mimeType = null;
String changeLog = StringPool.BLANK; String changeLog = StringPool.BLANK;
FileEntry fileEntry = null; FileEntry fileEntry = null;
Date now = new Date(); Date now = new Date();
long companyId = 0;
long groupId = 0;
long defaultFolderId = 0;
Folder defaultFolder = null;
String folderName = null;
byte[] bytes = null;
long folderId = 0;
long repositoryId = 0;
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
String className = ParamUtil.getString(actionRequest, "className"); String className = ParamUtil.getString(actionRequest, "className");
@ -117,18 +127,18 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
case "it.tref.liferay.portos.bo.model.DocPratica": case "it.tref.liferay.portos.bo.model.DocPratica":
DocPratica pratica = DocPraticaLocalServiceUtil.getDocPratica(idOggetto); DocPratica pratica = DocPraticaLocalServiceUtil.getDocPratica(idOggetto);
userId = pratica.getUserId(); userId = pratica.getUserId();
long companyId = pratica.getCompanyId(); companyId = pratica.getCompanyId();
long groupId = pratica.getGroupId(); groupId = pratica.getGroupId();
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(groupId); serviceContext.setScopeGroupId(groupId);
serviceContext.setUserId(userId); serviceContext.setUserId(userId);
long defaultFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID); defaultFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID);
Folder defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId); defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId);
String folderName = PraticaUtil.getFolderName(pratica.getClassPk()); folderName = PraticaUtil.getFolderName(pratica.getClassPk());
long folderId = defaultFolder.getFolderId(); folderId = defaultFolder.getFolderId();
long repositoryId = defaultFolder.getRepositoryId(); repositoryId = defaultFolder.getRepositoryId();
try { try {
folder = DLAppLocalServiceUtil.getFolder(repositoryId, folderId, folderName); folder = DLAppLocalServiceUtil.getFolder(repositoryId, folderId, folderName);
@ -137,16 +147,16 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
StringPool.BLANK, serviceContext); StringPool.BLANK, serviceContext);
} }
byte[] bytes = FileUtil.getBytes(file); bytes = FileUtil.getBytes(file);
title = pratica.getTipologia() + StringPool.UNDERLINE + sourceFileName; title = pratica.getTipologia() + StringPool.UNDERLINE + sourceFileName;
description = sourceFileName; description = sourceFileName;
mimeType = MimeTypesUtil.getContentType(sourceFileName); mimeType = MimeTypesUtil.getContentType(sourceFileName);
try { /*try {
DLAppLocalServiceUtil.deleteFileEntry(pratica.getDlFileEntryId()); DLAppLocalServiceUtil.deleteFileEntry(pratica.getDlFileEntryId());
} catch(PortalException e){ } catch(PortalException e){
} }*/
try { try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId()); fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId());
@ -157,14 +167,61 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_" + sourceFileName, fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_" + sourceFileName,
mimeType, title, description, changeLog, bytes, serviceContext); mimeType, title, description, changeLog, bytes, serviceContext);
} }
/*fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_"
+ sourceFileName, mimeType, title, description, changeLog, bytes, serviceContext);*/
pratica.setDlFileEntryId(fileEntry.getFileEntryId()); pratica.setDlFileEntryId(fileEntry.getFileEntryId());
pratica.setSha256(DigestUtils.sha256Hex(bytes)); pratica.setSha256(DigestUtils.sha256Hex(bytes));
DocPraticaLocalServiceUtil.updateDocPratica(pratica); DocPraticaLocalServiceUtil.updateDocPratica(pratica);
break; break;
case "it.tref.liferay.portos.bo.model.Pagamento":
Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(idOggetto);
userId = pagamento.getUserId();
companyId = pagamento.getCompanyId();
groupId = pagamento.getGroupId();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(groupId);
serviceContext.setUserId(userId);
defaultFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID);
defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId);
folderName = PraticaUtil.getFolderName(pagamento.getClassPk());
folderId = defaultFolder.getFolderId();
repositoryId = defaultFolder.getRepositoryId();
try {
folder = DLAppLocalServiceUtil.getFolder(repositoryId, folderId, folderName);
} catch (NoSuchFolderException e) {
folder = DLAppLocalServiceUtil.addFolder(userId, repositoryId, folderId, folderName,
StringPool.BLANK, serviceContext);
}
bytes = FileUtil.getBytes(file);
title = now.getTime() + StringPool.UNDERLINE + "pagamento_manuale" + StringPool.UNDERLINE
+ pagamento.getPagamentoId() + StringPool.UNDERLINE + sourceFileName;
description = StringPool.BLANK;
mimeType = MimeTypesUtil.getContentType(sourceFileName);
/*try {
DLAppLocalServiceUtil.deleteFileEntry(pagamento.getFileEntryId());
} catch(PortalException e){
}*/
try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(pagamento.getFileEntryId());
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(),
now.getTime() + "_" + sourceFileName, mimeType, title, description, changeLog, false, bytes,
serviceContext);
} catch (PortalException e) {
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_" + sourceFileName,
mimeType, title, description, changeLog, bytes, serviceContext);
}
pagamento.setFileEntryId(fileEntry.getFileEntryId());
PagamentoLocalServiceUtil.updatePagamento(pagamento);
break;
default: default:
break; break;

4
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties

@ -13,8 +13,8 @@
## ##
build.namespace=portos_bo build.namespace=portos_bo
build.number=2473 build.number=2474
build.date=1602256773674 build.date=1602316058194
build.auto.upgrade=true build.auto.upgrade=true
## ##

2
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp

@ -169,6 +169,8 @@ String dataProssimoSorteggio =
<aui:option label="Seleziona tipo di oggetto" value=""></aui:option> <aui:option label="Seleziona tipo di oggetto" value=""></aui:option>
<aui:option label="DocPratica (allegati)" selected="<%=oggetto.equals(DocPratica.class.getName())%>" <aui:option label="DocPratica (allegati)" selected="<%=oggetto.equals(DocPratica.class.getName())%>"
value="<%=DocPratica.class.getName()%>"></aui:option> value="<%=DocPratica.class.getName()%>"></aui:option>
<aui:option label="Pagamento (allegato)" selected="<%=oggetto.equals(Pagamento.class.getName())%>"
value="<%=Pagamento.class.getName()%>"></aui:option>
</aui:select> </aui:select>
<aui:input type="file" name="file" label="File" /> <aui:input type="file" name="file" label="File" />
<aui:input name="classPK" label="Id oggetto"> <aui:input name="classPK" label="Id oggetto">

Caricamento…
Annulla
Salva