mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1211: Generate hold report
* FileHoldReport capability added (and patched) * hold report type added to report model * hold template added, bootstraped (and patched) * UI action to file hold report added and sensitive to capability * report actions refactored into a single, general purpose, file report action (can be exposed as rule in future) * refactoring and extending of report generators (including declarative report generator) * unit test for file report action * integration test for hold report generation * added Sprin custom property editor registrar and registered QName property editor, this allows short name string forms of QNames to be specified and converted to QName from bean definitions (perhaps something useful for core) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@68235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -96,7 +96,17 @@ public abstract class AuditableActionExecuterAbstractBase extends ActionExecuter
|
||||
|
||||
if (auditable)
|
||||
{
|
||||
getAuditService().registerAuditEvent(this.getActionDefinition().getName(), this.getActionDefinition().getTitle());
|
||||
// get the details of the action
|
||||
String name = getActionDefinition().getName();
|
||||
String title = getActionDefinition().getTitle();
|
||||
if (title == null || title.isEmpty())
|
||||
{
|
||||
// default to name if no title available
|
||||
title = name;
|
||||
}
|
||||
|
||||
// register audit event
|
||||
getAuditService().registerAuditEvent(title, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -16,10 +16,7 @@
|
||||
* 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.Map;
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -36,16 +33,20 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Base class for the report action classes
|
||||
* File report generic action.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class BaseReportAction extends RMActionExecuterAbstractBase implements ReportModel
|
||||
public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel
|
||||
{
|
||||
/** action name */
|
||||
public static final String NAME = "fileReport";
|
||||
|
||||
/** Constants for the parameters passed from the UI */
|
||||
public static final String REPORT_TYPE = "reportType";
|
||||
public static final String DESTINATION = "destination";
|
||||
public static final String MIMETYPE= "mimetype";
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied";
|
||||
@@ -67,28 +68,30 @@ public abstract class BaseReportAction extends RMActionExecuterAbstractBase impl
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// TODO check that the actionedUponNodeRef is in a state to generate a destruction report
|
||||
// ie: is it eligable for destruction .. use fileDestructionReport capability!
|
||||
|
||||
// TODO allow the mimetype of the report to be specified as a parameter
|
||||
|
||||
// get the mimetype of the report
|
||||
String mimetype = (String)action.getParameterValue(MIMETYPE);
|
||||
if (mimetype == null || mimetype.isEmpty())
|
||||
{
|
||||
mimetype = MimetypeMap.MIMETYPE_HTML;
|
||||
}
|
||||
|
||||
// get the report type
|
||||
QName reportType = getReportType(action);
|
||||
Report report = reportService.generateReport(reportType, actionedUponNodeRef, MimetypeMap.MIMETYPE_HTML, addProperties(actionedUponNodeRef));
|
||||
|
||||
|
||||
// get the destination
|
||||
NodeRef destination = getDestination(action);
|
||||
|
||||
// generate the report
|
||||
Report report = reportService.generateReport(reportType, actionedUponNodeRef, mimetype);
|
||||
|
||||
// file the report
|
||||
NodeRef filedReport = reportService.fileReport(destination, report);
|
||||
|
||||
// return the report name
|
||||
String filedReportName = (String) nodeService.getProperty(filedReport, ContentModel.PROP_NAME);
|
||||
action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, filedReportName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
@@ -1181,7 +1181,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
||||
{
|
||||
List<AuditEvent> listAuditEvents = new ArrayList<AuditEvent>(this.auditEvents.size());
|
||||
listAuditEvents.addAll(this.auditEvents.values());
|
||||
Collections.sort(listAuditEvents, new AuditEvent());
|
||||
Collections.sort(listAuditEvents);
|
||||
return listAuditEvents;
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
|
||||
@@ -32,7 +31,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent>
|
||||
public class AuditEvent implements RecordsManagementModel, Comparable<AuditEvent>
|
||||
{
|
||||
/** Name */
|
||||
protected String name;
|
||||
@@ -55,15 +54,19 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
{
|
||||
ParameterCheck.mandatory("name", name);
|
||||
ParameterCheck.mandatory("label", label);
|
||||
|
||||
recordsManagementAuditService.registerAuditEvent(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
* Default constructor.
|
||||
*/
|
||||
public AuditEvent()
|
||||
{
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,6 +77,9 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
*/
|
||||
public AuditEvent(String name, String label)
|
||||
{
|
||||
ParameterCheck.mandatory("name", name);
|
||||
ParameterCheck.mandatory("label", label);
|
||||
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
}
|
||||
@@ -116,11 +122,14 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
* Compare by label.
|
||||
*
|
||||
* @param compare compare to audit event
|
||||
* @return int
|
||||
*/
|
||||
@Override
|
||||
public int compare(AuditEvent first, AuditEvent second)
|
||||
public int compareTo(AuditEvent compare)
|
||||
{
|
||||
return first.getLabel().compareTo(second.getLabel());
|
||||
return getLabel().compareTo(compare.getLabel());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.patch.common;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Abstract implementation of capability patch.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class CapabilityPatch extends AbstractModulePatch
|
||||
{
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/** File plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/**
|
||||
* @param filePlanRoleService file plan role service
|
||||
*/
|
||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
||||
{
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the file plans
|
||||
*
|
||||
* @return Set of file plan node references
|
||||
*/
|
||||
protected Set<NodeRef> getFilePlans()
|
||||
{
|
||||
return filePlanService.getFilePlans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new capability to the specified roles.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
* @param capabilityName capability name
|
||||
* @param roles roles
|
||||
*/
|
||||
protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
|
||||
{
|
||||
Capability capability = capabilityService.getCapability(capabilityName);
|
||||
if (capability == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can't patch capabilities, because capability " + capabilityName + " does not exist.");
|
||||
}
|
||||
|
||||
for (String roleName : roles)
|
||||
{
|
||||
Role role = filePlanRoleService.getRole(filePlan, roleName);
|
||||
|
||||
if (role != null)
|
||||
{
|
||||
// get the roles current capabilities
|
||||
Set<Capability> capabilities = role.getCapabilities();
|
||||
|
||||
// only update if the capability is missing
|
||||
if (!capabilities.contains(capability))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
|
||||
}
|
||||
|
||||
capabilities.add(capability);
|
||||
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
|
||||
*/
|
||||
@Override
|
||||
public void applyInternal()
|
||||
{
|
||||
Set<NodeRef> filePlans = getFilePlans();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" ... updating " + filePlans.size() + " file plans");
|
||||
}
|
||||
|
||||
for (NodeRef filePlan : filePlans)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" ... updating file plan " + filePlan.toString());
|
||||
}
|
||||
|
||||
// apply the capability patch to each file plan
|
||||
applyCapabilityPatch(filePlan);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void applyCapabilityPatch(NodeRef filePlan);
|
||||
}
|
@@ -18,15 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.patch.v22;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -35,128 +28,29 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.2
|
||||
*/
|
||||
public class RMv22CapabilityPatch extends AbstractModulePatch
|
||||
public class RMv22CapabilityPatch extends CapabilityPatch
|
||||
{
|
||||
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/** File plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/**
|
||||
* @param filePlanRoleService file plan role service
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
||||
protected void applyCapabilityPatch(NodeRef filePlan)
|
||||
{
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the file plans
|
||||
*
|
||||
* @return Set of file plan node references
|
||||
*/
|
||||
protected Set<NodeRef> getFilePlans()
|
||||
{
|
||||
return filePlanService.getFilePlans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new capability to the specified roles.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
* @param capabilityName capability name
|
||||
* @param roles roles
|
||||
*/
|
||||
protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
|
||||
{
|
||||
Capability capability = capabilityService.getCapability(capabilityName);
|
||||
if (capability == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to bootstrap RMv21 capabilities, because capability " + capabilityName + " does not exist.");
|
||||
}
|
||||
|
||||
for (String roleName : roles)
|
||||
{
|
||||
Role role = filePlanRoleService.getRole(filePlan, roleName);
|
||||
|
||||
if (role != null)
|
||||
{
|
||||
// get the roles current capabilities
|
||||
Set<Capability> capabilities = role.getCapabilities();
|
||||
|
||||
// only update if the capability is missing
|
||||
if (!capabilities.contains(capability))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
|
||||
}
|
||||
|
||||
capabilities.add(capability);
|
||||
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
|
||||
*/
|
||||
@Override
|
||||
public void applyInternal()
|
||||
{
|
||||
Set<NodeRef> filePlans = getFilePlans();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" ... updating " + filePlans.size() + " file plans");
|
||||
}
|
||||
|
||||
for (NodeRef filePlan : filePlans)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" ... updating file plan " + filePlan.toString());
|
||||
}
|
||||
|
||||
// add new capability
|
||||
addCapability(filePlan,
|
||||
"FileDestructionReport",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
addCapability(filePlan,
|
||||
"CreateHold",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
addCapability(filePlan,
|
||||
"AddToHold",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
addCapability(filePlan,
|
||||
"RemoveFromHold",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
}
|
||||
// add new capability
|
||||
addCapability(filePlan,
|
||||
"FileDestructionReport",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
addCapability(filePlan,
|
||||
"CreateHold",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
addCapability(filePlan,
|
||||
"AddToHold",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
addCapability(filePlan,
|
||||
"RemoveFromHold",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.patch.v22;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* RM v2.2 patch to add FileHoldReport capability.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class RMv22FileHoldReportCapabilityPatch extends CapabilityPatch
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.patch.common.CapabilityPatch#applyCapabilityPatch(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
protected void applyCapabilityPatch(NodeRef filePlan)
|
||||
{
|
||||
// add new capability
|
||||
addCapability(filePlan,
|
||||
"FileHoldReport",
|
||||
FilePlanRoleService.ROLE_ADMIN,
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER);
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.patch.v22;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Adds the hold report.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class RMv22HoldReportPatch extends AbstractModulePatch
|
||||
{
|
||||
/** Report template path */
|
||||
private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_holdReport.html.ftl";
|
||||
|
||||
/** Report template config node IDs */
|
||||
private static final NodeRef REPORT_FOLDER = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates");
|
||||
private static final NodeRef REPORT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rmr_holdReport");
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Content service */
|
||||
private ContentService contentService;
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentService content service
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
|
||||
*/
|
||||
@Override
|
||||
public void applyInternal()
|
||||
{
|
||||
if (!nodeService.exists(REPORT))
|
||||
{
|
||||
// get the assoc qname
|
||||
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_holdReport.html.ftl"));
|
||||
|
||||
// build the node properties
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4);
|
||||
props.put(ContentModel.PROP_DESCRIPTION, "Hold report template.");
|
||||
props.put(ContentModel.PROP_TITLE, "Hold Report Template");
|
||||
props.put(ContentModel.PROP_NAME, "report_rmr_holdReport.html.ftl");
|
||||
props.put(ContentModel.PROP_NODE_UUID, "rmr_holdReport");
|
||||
|
||||
// create the node
|
||||
ChildAssociationRef node = nodeService.createNode(
|
||||
REPORT_FOLDER,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
assocQName,
|
||||
ContentModel.TYPE_CONTENT,
|
||||
props);
|
||||
|
||||
// put the content
|
||||
ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true);
|
||||
InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH);
|
||||
writer.putContent(is);
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,12 +32,24 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public interface Report
|
||||
{
|
||||
/**
|
||||
* @return {@link QName} report type
|
||||
*/
|
||||
QName getReportType();
|
||||
|
||||
/**
|
||||
* @return {@link String} report name
|
||||
*/
|
||||
String getReportName();
|
||||
|
||||
/**
|
||||
* @return {@link Map}<{@link QName},{@link Serializable}> report properties
|
||||
*/
|
||||
Map<QName, Serializable> getReportProperties();
|
||||
|
||||
/**
|
||||
* @return {@link ContentReader} content reader to report content
|
||||
*/
|
||||
ContentReader getReportContent();
|
||||
|
||||
}
|
||||
|
@@ -18,21 +18,28 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.report;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Report generator interface.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ReportGenerator
|
||||
{
|
||||
/**
|
||||
* @return {@link QName} report type
|
||||
*/
|
||||
QName getReportType();
|
||||
|
||||
/**
|
||||
* Generate report.
|
||||
*
|
||||
* @param reportedUponNodeRef
|
||||
* @param mimetype
|
||||
* @return
|
||||
*/
|
||||
Report generateReport(NodeRef reportedUponNodeRef, String mimetype);
|
||||
|
||||
Report generateReport(NodeRef reportedUponNodeRef, String mimetype, Map<String, Serializable> properties);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -24,14 +24,26 @@ import org.alfresco.service.namespace.QName;
|
||||
* Helper class containing records management report qualified names
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ReportModel
|
||||
{
|
||||
// Namespace details
|
||||
/** Namespace details */
|
||||
String RMR_URI = "http://www.alfresco.org/model/recordsmanagementreport/1.0";
|
||||
String RMR_PREFIX = "rmr";
|
||||
|
||||
/** base report type */
|
||||
QName TYPE_REPORT = QName.createQName(RMR_URI, "report");
|
||||
|
||||
/** destruction report type */
|
||||
QName TYPE_DESTRUCTION_REPORT = QName.createQName(RMR_URI, "destructionReport");
|
||||
|
||||
/** transfer report type */
|
||||
QName TYPE_TRANSFER_REPORT = QName.createQName(RMR_URI, "transferReport");
|
||||
|
||||
/**
|
||||
* hold report type
|
||||
* @since 2.2
|
||||
*/
|
||||
QName TYPE_HOLD_REPORT = QName.createQName(RMR_URI, "holdReport");
|
||||
}
|
||||
|
@@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.report;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -43,36 +41,31 @@ public interface ReportService
|
||||
/**
|
||||
* Get a list of the available report types.
|
||||
*
|
||||
* @return
|
||||
* @return {@link Set}<{@link QName}> list of the available report types
|
||||
*/
|
||||
Set<QName> getReportTypes();
|
||||
|
||||
/**
|
||||
* Generate a report of the given type and reported upon node reference.
|
||||
*
|
||||
*
|
||||
* @param reportType
|
||||
* @param reportedUponNodeRef
|
||||
* @return
|
||||
* @param reportType report type
|
||||
* @param reportedUponNodeRef reported upon node reference
|
||||
* @return {@link Report} generated report
|
||||
*/
|
||||
Report generateReport(QName reportType, NodeRef reportedUponNodeRef);
|
||||
|
||||
/**
|
||||
* Generate a report for a specified mimetype.
|
||||
*
|
||||
* @see #generateReport(QName, NodeRef)
|
||||
*
|
||||
* @param reportType
|
||||
* @param reportedUponNodeRef
|
||||
* @return
|
||||
* @param reportType report type
|
||||
* @param reportedUponNodeRef report upon node reference
|
||||
* @param mimetype report mimetype
|
||||
* @return {@link Report} generated report
|
||||
*/
|
||||
Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype);
|
||||
|
||||
/**
|
||||
* @param reportType
|
||||
* @param reportedUponNodeRef
|
||||
* @param mimetype
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype, Map<String, Serializable> properties);
|
||||
|
||||
/**
|
||||
* File report in the given destination. If the given node reference is a file plan node
|
||||
* reference the report will be filed in the unfiled records container.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.report;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -95,20 +94,6 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef);
|
||||
ParameterCheck.mandatoryString("mimetype", mimetype);
|
||||
|
||||
return generateReport(reportType, reportedUponNodeRef, mimetype, new HashMap<String, Serializable>(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportService#generateReport(QName, NodeRef, String, Map)
|
||||
*/
|
||||
@Override
|
||||
public Report generateReport(QName reportType, NodeRef reportedUponNodeRef, String mimetype, Map<String, Serializable> properties)
|
||||
{
|
||||
ParameterCheck.mandatory("reportType", reportType);
|
||||
ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef);
|
||||
ParameterCheck.mandatoryString("mimetype", mimetype);
|
||||
ParameterCheck.mandatory("properties", properties);
|
||||
|
||||
// get the generator
|
||||
ReportGenerator generator = registry.get(reportType);
|
||||
|
||||
@@ -119,7 +104,7 @@ public class ReportServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
|
||||
// generate the report
|
||||
return generator.generateReport(reportedUponNodeRef, mimetype, properties);
|
||||
return generator.generateReport(reportedUponNodeRef, mimetype);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "destructionReport";
|
||||
|
||||
@Override
|
||||
protected Map<String, Serializable> addProperties(NodeRef nodeRef)
|
||||
{
|
||||
return new HashMap<String, Serializable>(1);
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -19,9 +19,9 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.generator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.Report;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||
@@ -32,79 +32,119 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Base report generator.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract class BaseReportGenerator implements ReportGenerator
|
||||
{
|
||||
/** report service */
|
||||
protected ReportService reportService;
|
||||
|
||||
/** namespace service */
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
protected String reportTypeName;
|
||||
|
||||
/** report type qualified name */
|
||||
protected QName reportType;
|
||||
|
||||
/**
|
||||
* @param reportService report service
|
||||
*/
|
||||
public void setReportService(ReportService reportService)
|
||||
{
|
||||
this.reportService = reportService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService namespace service
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
public void setReportTypeName(String reportTypeName)
|
||||
|
||||
/**
|
||||
* @param reportType report type
|
||||
*/
|
||||
public void setReportType(QName reportType)
|
||||
{
|
||||
this.reportTypeName = reportTypeName;
|
||||
this.reportType = reportType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator#getReportType()
|
||||
*/
|
||||
@Override
|
||||
public QName getReportType()
|
||||
{
|
||||
return reportType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
// convert type name to QName
|
||||
reportType = QName.createQName(reportTypeName, namespaceService);
|
||||
|
||||
// ensure required values have been set
|
||||
ParameterCheck.mandatory("reportType", reportType);
|
||||
|
||||
// register report generator
|
||||
reportService.registerReportGenerator(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.ReportGenerator#generateReport(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public Report generateReport(NodeRef reportedUponNodeRef, String mimetype)
|
||||
{
|
||||
ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef);
|
||||
ParameterCheck.mandatoryString("mimetype", mimetype);
|
||||
|
||||
return generateReport(reportedUponNodeRef, mimetype, new HashMap<String, Serializable>(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Report generateReport(NodeRef reportedUponNodeRef, String mimetype, Map<String, Serializable> properties)
|
||||
{
|
||||
ParameterCheck.mandatory("reportedUponNodeRef", reportedUponNodeRef);
|
||||
ParameterCheck.mandatoryString("mimetype", mimetype);
|
||||
ParameterCheck.mandatory("properties", properties);
|
||||
|
||||
String reportName = generateReportName(reportedUponNodeRef);
|
||||
Map<QName, Serializable> reportProperties = generateReportProperties(reportedUponNodeRef);
|
||||
ContentReader contentReader = generateReportContent(reportedUponNodeRef, mimetype, properties);
|
||||
// check the applicability of the report generator for the given reported upon node
|
||||
checkReportApplicability(reportedUponNodeRef);
|
||||
|
||||
// generate the report name
|
||||
String reportName = generateReportName(reportedUponNodeRef, mimetype);
|
||||
|
||||
// generate the report meta-data
|
||||
Map<QName, Serializable> reportProperties = generateReportMetadata(reportedUponNodeRef);
|
||||
|
||||
// generate the report content
|
||||
ContentReader contentReader = generateReportContent(reportedUponNodeRef, mimetype, generateReportTemplateContext(reportedUponNodeRef));
|
||||
|
||||
// return the report information object
|
||||
return new ReportInfo(reportType, reportName, reportProperties, contentReader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the report generator is applicable given the reported upon node reference.
|
||||
* <p>
|
||||
* Throws AlfrescoRuntimeException if applicability fails, with reason.
|
||||
*
|
||||
* @param reportedUponNodeRef reported upon node reference
|
||||
* @throws AlfrescoRuntimeException if applicability check fails
|
||||
*/
|
||||
protected abstract void checkReportApplicability(NodeRef reportedUponNodeRef) throws AlfrescoRuntimeException;
|
||||
|
||||
protected abstract String generateReportName(NodeRef reportedUponNodeRef);
|
||||
/**
|
||||
* Generate the report name
|
||||
*/
|
||||
protected abstract String generateReportName(NodeRef reportedUponNodeRef, String mimetype);
|
||||
|
||||
protected Map<QName, Serializable> generateReportProperties(NodeRef reportedUponNodeRef)
|
||||
{
|
||||
// default implementation
|
||||
return new HashMap<QName, Serializable>(0);
|
||||
}
|
||||
/**
|
||||
* Generate the report template context.
|
||||
*/
|
||||
protected abstract Map<String, Serializable> generateReportTemplateContext(NodeRef reportedUponNodeRef);
|
||||
|
||||
/**
|
||||
* Generate report meta-data
|
||||
*/
|
||||
protected abstract Map<QName, Serializable> generateReportMetadata(NodeRef reportedUponNodeRef);
|
||||
|
||||
/**
|
||||
* Generate report content
|
||||
*/
|
||||
protected abstract ContentReader generateReportContent(NodeRef reportedUponNodeRef, String mimetype, Map<String, Serializable> properties);
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -19,21 +19,28 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.generator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.action.parameter.ParameterProcessorComponent;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.SysAdminParams;
|
||||
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.UrlUtil;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
@@ -45,12 +52,18 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*/
|
||||
public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
{
|
||||
/** message lookups */
|
||||
protected static final String MSG_REPORT = "report.default";
|
||||
|
||||
/** template lookup root */
|
||||
protected static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates");
|
||||
|
||||
/** model keys */
|
||||
protected static final String KEY_NODE = "node";
|
||||
protected static final String KEY_CHILDREN = "children";
|
||||
|
||||
/** applicable reported upon types */
|
||||
protected Set<QName> applicableTypes;
|
||||
|
||||
/** content service */
|
||||
protected ContentService contentService;
|
||||
@@ -67,12 +80,23 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
/** repository helper */
|
||||
protected Repository repository;
|
||||
|
||||
/** parameter processor component */
|
||||
protected ParameterProcessorComponent parameterProcessorComponent;
|
||||
|
||||
/** node service */
|
||||
protected NodeService nodeService;
|
||||
|
||||
/** dictionary service */
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
/** sys admin params */
|
||||
protected SysAdminParams sysAdminParams;
|
||||
|
||||
/**
|
||||
* @param applicableTypes applicable types
|
||||
*/
|
||||
public void setApplicableTypes(Set<QName> applicableTypes)
|
||||
{
|
||||
this.applicableTypes = applicableTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimetypeService mimetype service
|
||||
*/
|
||||
@@ -106,11 +130,19 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameterProcessorComponent parameter processor component
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent)
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.parameterProcessorComponent = parameterProcessorComponent;
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,16 +160,47 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
{
|
||||
this.sysAdminParams = sysAdminParams;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportName(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected String generateReportName(NodeRef reportedUponNodeRef)
|
||||
protected String generateReportName(NodeRef reportedUponNodeRef, String mimetype)
|
||||
{
|
||||
String reportTypeName = reportType.getPrefixedQName(namespaceService).getPrefixString().replace(":", "_");
|
||||
String value = I18NUtil.getMessage("report." + reportTypeName + ".name");
|
||||
return parameterProcessorComponent.process(value, reportedUponNodeRef);
|
||||
// get the file extension based on the mimetype
|
||||
String extension = mimetypeService.getExtension(mimetype);
|
||||
|
||||
// get the name of the reported updon node ref
|
||||
String name = (String)nodeService.getProperty(reportedUponNodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
// build default report name
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(getReportDisplayLabel());
|
||||
if (name != null & !name.isEmpty())
|
||||
{
|
||||
builder.append(" - ").append(name);
|
||||
}
|
||||
builder.append(".").append(extension);
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the report types display label
|
||||
*
|
||||
* @return {@link String} report type display label
|
||||
*/
|
||||
private String getReportDisplayLabel()
|
||||
{
|
||||
String result = I18NUtil.getMessage(MSG_REPORT);
|
||||
|
||||
TypeDefinition typeDef = dictionaryService.getType(reportType);
|
||||
if (typeDef != null)
|
||||
{
|
||||
result = typeDef.getTitle(new StaticMessageLookup());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,6 +228,14 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
return contentWriter.getReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create template model.
|
||||
*
|
||||
* @param templateNodeRef
|
||||
* @param reportedUponNodeRef
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
protected Map<String, Serializable> createTemplateModel(NodeRef templateNodeRef, NodeRef reportedUponNodeRef, Map<String, Serializable> properties)
|
||||
{
|
||||
Map<String, Serializable> model = new HashMap<String, Serializable>();
|
||||
@@ -214,8 +285,6 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
|
||||
// get localise template
|
||||
return fileFolderService.getLocalizedSibling(reportTemplateNodeRef);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,4 +308,52 @@ public class DeclarativeReportGenerator extends BaseReportGenerator
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#checkReportApplicability(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void checkReportApplicability(NodeRef reportedUponNodeRef) throws AlfrescoRuntimeException
|
||||
{
|
||||
if (applicableTypes != null && applicableTypes.size() != 0)
|
||||
{
|
||||
boolean isTypeApplicable = false;
|
||||
QName type = nodeService.getType(reportedUponNodeRef);
|
||||
|
||||
for (QName applicableType : applicableTypes)
|
||||
{
|
||||
if (dictionaryService.isSubClass(type, applicableType))
|
||||
{
|
||||
isTypeApplicable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTypeApplicable)
|
||||
{
|
||||
// throw an exception
|
||||
throw new AlfrescoRuntimeException("Can't generate report, because the provided reported upon node reference is type " + type.toString() +
|
||||
" which is not an applicable type for a " + reportType.toString() + " report.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportTemplateContext(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Map<String, Serializable> generateReportTemplateContext(NodeRef reportedUponNodeRef)
|
||||
{
|
||||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportMetadata(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Map<QName, Serializable> generateReportMetadata(NodeRef reportedUponNodeRef)
|
||||
{
|
||||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
}
|
||||
|
@@ -45,6 +45,14 @@ import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
/** content reader */
|
||||
private ContentReader reportContent;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param reportType report type
|
||||
* @param reportName report name
|
||||
* @param reportProperties report properties
|
||||
* @param reportContent report content reader
|
||||
*/
|
||||
public ReportInfo(QName reportType, String reportName, Map<QName, Serializable> reportProperties, ContentReader reportContent)
|
||||
{
|
||||
ParameterCheck.mandatory("reportType", reportType);
|
||||
@@ -57,22 +65,35 @@ import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
this.reportContent = reportContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportType()
|
||||
*/
|
||||
public QName getReportType()
|
||||
{
|
||||
return reportType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportName()
|
||||
*/
|
||||
@Override
|
||||
public String getReportName()
|
||||
{
|
||||
return reportName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportProperties()
|
||||
*/
|
||||
@Override
|
||||
public Map<QName, Serializable> getReportProperties()
|
||||
{
|
||||
return reportProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.Report#getReportContent()
|
||||
*/
|
||||
@Override
|
||||
public ContentReader getReportContent()
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
* 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;
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.generator.transfer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
* 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;
|
||||
package org.alfresco.module.org_alfresco_module_rm.report.generator.transfer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -27,7 +27,9 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGenerator;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -35,21 +37,33 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* Transfer report action
|
||||
*
|
||||
* Transfer report generator.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class TransferReportAction extends BaseReportAction
|
||||
public class TransferReportGenerator extends DeclarativeReportGenerator
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "transferReport";
|
||||
|
||||
/** dispotion service */
|
||||
protected DispositionService dispositionService;
|
||||
|
||||
/**
|
||||
* @param dispositionService disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGeneratorUnitTest#generateReportTemplateContext(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Serializable> addProperties(NodeRef nodeRef)
|
||||
protected Map<String, Serializable> generateReportTemplateContext(NodeRef reportedUponNodeRef)
|
||||
{
|
||||
// Get all 'transferred' nodes
|
||||
List<TransferNode> transferNodes = getTransferNodes(nodeRef);
|
||||
List<TransferNode> transferNodes = getTransferNodes(reportedUponNodeRef);
|
||||
|
||||
// Get the disposition authority
|
||||
String dispositionAuthority = getDispositionAuthority(transferNodes);
|
||||
@@ -215,4 +229,5 @@ public class TransferReportAction extends BaseReportAction
|
||||
}
|
||||
return dispositionAuthority == null ? StringUtils.EMPTY : dispositionAuthority;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.util;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.beans.PropertyEditorRegistrar;
|
||||
import org.springframework.beans.PropertyEditorRegistry;
|
||||
|
||||
/**
|
||||
* Custom property editor registrar.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class CustomPropertyEditorRegistrar implements PropertyEditorRegistrar
|
||||
{
|
||||
/** namespace service */
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
/**
|
||||
* @param namespaceService namespace service
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.PropertyEditorRegistrar#registerCustomEditors(org.springframework.beans.PropertyEditorRegistry)
|
||||
*/
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry)
|
||||
{
|
||||
// add custom QName editor
|
||||
registry.registerCustomEditor(QName.class, new QNameTypeEditor(namespaceService));
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.util;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* QName type editor.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class QNameTypeEditor extends PropertyEditorSupport
|
||||
{
|
||||
/** namespace service */
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
/**
|
||||
* @param namespaceService namespace service
|
||||
*/
|
||||
public QNameTypeEditor(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException
|
||||
{
|
||||
// convert prefix string to QName
|
||||
setValue(QName.createQName(text, namespaceService));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user