use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class TransferReportPost method generateHTMLTransferReport.
/**
* Generates a File containing the JSON representation of a transfer report.
*
* @param transferNode The transfer node
* @return File containing JSON representation of a transfer report
* @throws IOException
*/
File generateHTMLTransferReport(NodeRef transferNode) throws IOException {
File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX);
// create the writer
try (FileOutputStream fileOutputStream = new FileOutputStream(report);
Writer writer = new OutputStreamWriter(fileOutputStream, Charset.forName("UTF-8"))) {
// get all 'transferred' nodes
NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
if (logger.isDebugEnabled()) {
logger.debug("Generating HTML transfer report for " + itemsToTransfer.length + " items into file: " + report.getAbsolutePath());
}
// 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();
}
}
// write the HTML header
writer.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
writer.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n");
Boolean isAccession = (Boolean) this.nodeService.getProperty(transferNode, PROP_TRANSFER_ACCESSION_INDICATOR);
if (isAccession) {
writer.write("<title>Accession Report</title></head>\n");
} else {
writer.write("<title>Transfer Report</title></head>\n");
}
writer.write("<style>\n");
writer.write("body { font-family: arial,verdana; font-size: 81%; color: #333; }\n");
writer.write(".records { margin-left: 20px; margin-top: 10px; }\n");
writer.write(".record { padding: 5px; }\n");
writer.write(".label { color: #111; }\n");
writer.write(".nodeName { font-weight: bold; }\n");
writer.write(".transferred-item { background-color: #eee; padding: 10px; margin-bottom: 15px; }\n");
writer.write("</style>\n");
if (isAccession) {
writer.write("<body>\n<h1>Accession Report</h1>\n");
} else {
writer.write("<body>\n<h1>Transfer Report</h1>\n");
}
writer.write("<table cellpadding=\"3\" cellspacing=\"3\">");
writer.write("<tr><td class=\"label\">Transfer Date:</td><td>");
Date transferDate = (Date) this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED);
writer.write(StringEscapeUtils.escapeHtml(transferDate.toString()));
writer.write("</td></tr>");
writer.write("<tr><td class=\"label\">Transfer Location:</td><td>");
if (isAccession) {
writer.write("NARA");
} else {
writer.write(StringEscapeUtils.escapeHtml((String) this.nodeService.getProperty(transferNode, RecordsManagementModel.PROP_TRANSFER_LOCATION)));
}
writer.write("</td></tr>");
writer.write("<tr><td class=\"label\">Performed By:</td><td>");
writer.write(StringEscapeUtils.escapeHtml((String) this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATOR)));
writer.write("</td></tr>");
writer.write("<tr><td class=\"label\">Disposition Authority:</td><td>");
writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml(dispositionAuthority) : "");
writer.write("</td></tr></table>\n");
writer.write("<h2>Transferred Items</h2>\n");
// write out HTML representation of items to transfer
generateTransferItemsHTML(writer, itemsToTransfer);
// write the HTML footer
writer.write("</body></html>");
}
return report;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class DispositionActionDefinitionPut method executeImpl.
/*
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
// parse the request to retrieve the schedule object
DispositionSchedule schedule = parseRequestForSchedule(req);
// parse the request to retrieve the action definition object
DispositionActionDefinition actionDef = parseRequestForActionDefinition(req, schedule);
// retrieve the rest of the post body and update the action definition
JSONObject json = null;
try {
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
actionDef = updateActionDefinition(actionDef, json);
} catch (IOException iox) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
} catch (JSONException je) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
}
// create model object with just the action data
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("action", createActionDefModel(actionDef, req.getURL()));
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class ApiNodesModelFactory method mapRecordCategoryChildInfo.
/**
* Helper method that sets the information for record category child type.
*
* @param recordCategoryChild the record category child to set the fields to
* @param info info of the record category child
* @param includeParam the requested include parameters
* @param propertyFilter
*/
private void mapRecordCategoryChildInfo(RecordCategoryChild recordCategoryChild, FileInfo info, List<String> includeParam, BeanPropertiesFilter propertyFilter, boolean isMinimalInfo) {
if (isMinimalInfo && (includeParam == null || includeParam.isEmpty())) {
return;
}
if (RecordsManagementModel.TYPE_RECORD_FOLDER.equals(info.getType())) {
if ((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_FOLDER)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_FOLDER))) {
recordCategoryChild.setIsRecordFolder(true);
}
if ((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY))) {
recordCategoryChild.setIsRecordCategory(false);
}
if ((!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_IS_CLOSED)) || (isMinimalInfo && includeParam.contains(RMNode.PARAM_IS_CLOSED))) {
recordCategoryChild.setIsClosed((Boolean) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_IS_CLOSED));
}
if (includeParam.contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE)) {
recordCategoryChild.setHasRetentionSchedule(null);
}
} else {
if ((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_FOLDER)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_FOLDER))) {
recordCategoryChild.setIsRecordFolder(false);
}
if ((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY))) {
recordCategoryChild.setIsRecordCategory(true);
}
if (includeParam.contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE)) {
DispositionSchedule ds = dispositionService.getDispositionSchedule(info.getNodeRef());
recordCategoryChild.setHasRetentionSchedule(ds != null ? true : false);
}
if ((!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_IS_CLOSED)) || (isMinimalInfo && includeParam.contains(RMNode.PARAM_IS_CLOSED))) {
recordCategoryChild.setIsClosed(null);
}
}
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class ApiNodesModelFactory method createRecordCategory.
/**
* Creates an object of type RecordCategory
*
* @param info info of the record category
* @param propertyFilter
* @param includeParam
* @param mapUserInfo
* @param isMinimalInfo
* @return RecordCategory object
*/
public RecordCategory createRecordCategory(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo) {
RecordCategory recordCategory = new RecordCategory();
mapBasicInfo(recordCategory, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
mapOptionalInfo(recordCategory, info, parameters.getInclude(), isMinimalInfo);
if (parameters.getInclude().contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE)) {
DispositionSchedule ds = dispositionService.getDispositionSchedule(info.getNodeRef());
recordCategory.setHasRetentionSchedule(ds != null ? true : false);
}
return recordCategory;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule in project records-management by Alfresco.
the class RecordsManagementNodeFormFilter method afterGenerate.
/**
* @see org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, java.util.List, java.util.List, org.alfresco.repo.forms.Form, java.util.Map)
*/
@Override
public void afterGenerate(NodeRef nodeRef, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context) {
if (getFilePlanService().isFilePlanComponent(nodeRef)) {
// add all the custom properties
addCustomPropertyFieldsToGroup(form, nodeRef);
FilePlanComponentKind kind = getFilePlanService().getFilePlanComponentKind(nodeRef);
if (FilePlanComponentKind.RECORD.equals(kind)) {
// add all the record meta-data aspect properties
addRecordMetadataPropertyFieldsToGroup(form, nodeRef);
// add required transient properties
addTransientProperties(form, nodeRef);
// add the supplemental marking list property
forceSupplementalMarkingListProperty(form, nodeRef);
// protect uneditable properties
protectRecordProperties(form, nodeRef);
// if the record is the result of an email we need to 'protect' some fields
if (this.nodeService.hasAspect(nodeRef, ImapModel.ASPECT_IMAP_CONTENT)) {
protectEmailExtractedFields(form, nodeRef);
}
} else if (FilePlanComponentKind.RECORD_FOLDER.equals(kind)) {
// add the supplemental marking list property
forceSupplementalMarkingListProperty(form, nodeRef);
// add required transient properties
addTransientProperties(form, nodeRef);
} else if (FilePlanComponentKind.DISPOSITION_SCHEDULE.equals(kind)) {
// use the same mechanism used to determine whether steps can be removed from the
// schedule to determine whether the disposition level can be changed i.e. record
// level or folder level.
DispositionSchedule schedule = new DispositionScheduleImpl(this.rmServiceRegistry, this.nodeService, nodeRef);
if (getDispositionService().hasDisposableItems(schedule)) {
protectRecordLevelDispositionPropertyField(form);
}
}
}
}
Aggregations