mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1099 (Refactor Transfer and Accession reports)
* Created a base report action and splitted the file report action to transfer report action and destruction report action, so that capability checks can be run for those actions separately and each action can pass additional properties to the report template model git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58444 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,11 +18,15 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.Report;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -30,12 +34,12 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* File report action
|
||||
* Base class for the report action classes
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel
|
||||
public abstract class BaseReportAction extends RMActionExecuterAbstractBase implements ReportModel
|
||||
{
|
||||
/** Constants for the parameters passed from the UI */
|
||||
public static final String REPORT_TYPE = "reportType";
|
||||
@@ -67,12 +71,19 @@ public class FileReportAction extends RMActionExecuterAbstractBase implements Re
|
||||
// TODO allow the mimetype of the report to be specified as a parameter
|
||||
|
||||
QName reportType = getReportType(action);
|
||||
Report report = reportService.generateReport(reportType, actionedUponNodeRef);
|
||||
Report report = reportService.generateReport(reportType, actionedUponNodeRef, MimetypeMap.MIMETYPE_HTML, addProperties(actionedUponNodeRef));
|
||||
|
||||
NodeRef destination = getDestination(action);
|
||||
reportService.fileReport(destination, report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives other action classes to pass additional properties for the template model
|
||||
*
|
||||
* @return Properties which are passed to the template model
|
||||
*/
|
||||
protected abstract Map<String, Serializable> addProperties(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Retrieves the value of the given parameter. If the parameter has not been passed from the UI an error will be thrown
|
||||
*
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Destruction report action
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public class DestructionReportAction extends BaseReportAction
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Serializable> addProperties(NodeRef nodeRef)
|
||||
{
|
||||
return new HashMap<String, Serializable>(1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* Transfer report action
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public class TransferReportAction extends BaseReportAction
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Serializable> addProperties(NodeRef nodeRef)
|
||||
{
|
||||
// Get all 'transferred' nodes
|
||||
NodeRef[] transferNodes = getTransferNodes(nodeRef);
|
||||
|
||||
// Get the disposition authority
|
||||
String dispositionAuthority = getDispositionAuthority(transferNodes);
|
||||
|
||||
// Save to the properties map
|
||||
Map<String, Serializable> properties = new HashMap<String, Serializable>(2);
|
||||
properties.put("transferNodes", transferNodes);
|
||||
properties.put("dispositionAuthority", dispositionAuthority);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of NodeRefs representing the items to be transferred.
|
||||
*
|
||||
* @param transferNode The transfer object
|
||||
* @return Array of NodeRefs
|
||||
*/
|
||||
private NodeRef[] getTransferNodes(NodeRef transferNode)
|
||||
{
|
||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(transferNode,
|
||||
RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL);
|
||||
NodeRef[] itemsToTransfer = new NodeRef[assocs.size()];
|
||||
for (int idx = 0; idx < assocs.size(); idx++)
|
||||
{
|
||||
itemsToTransfer[idx] = assocs.get(idx).getChildRef();
|
||||
}
|
||||
return itemsToTransfer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the disposition authority from the array of the transfer objects
|
||||
*
|
||||
* @param itemsToTransfer The transfer objects
|
||||
* @return Disposition authority
|
||||
*/
|
||||
private String getDispositionAuthority(NodeRef[] itemsToTransfer)
|
||||
{
|
||||
// use RMService to get disposition authority
|
||||
String dispositionAuthority = null;
|
||||
if (itemsToTransfer.length > 0)
|
||||
{
|
||||
// use the first transfer item to get to disposition schedule
|
||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]);
|
||||
if (ds != null)
|
||||
{
|
||||
dispositionAuthority = ds.getDispositionAuthority();
|
||||
}
|
||||
}
|
||||
return dispositionAuthority == null ? StringUtils.EMPTY : dispositionAuthority;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user