use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ZkReportViewer method cmd_archive.
// cmd_sendMail
/**
* Archive Report directly
*/
private void cmd_archive() {
boolean success = false;
// No Copy
byte[] data = Document.getPDFAsArray(m_reportEngine.getLayout().getPageable(false));
if (data != null) {
MArchive archive = new MArchive(Env.getCtx(), m_reportEngine.getPrintInfo(), null);
archive.setBinaryData(data);
success = archive.save();
}
if (success)
FDialog.info(m_WindowNo, this, "Archived");
else
FDialog.error(m_WindowNo, this, "ArchiveError");
}
use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ZkJRViewer method cmd_archive.
// cmd_sendMail
/**
*
* Create a Archive for specified report
* Create an entry at AD_Archive table
*
*/
private void cmd_archive() {
boolean success = false;
byte[] data = getPDFAsArray(file);
MArchive arc = null;
if (data != null) {
PrintInfo printInfo = null;
if (null != processInfo) {
printInfo = new PrintInfo(processInfo);
}
if (null != printInfo) {
arc = new MArchive(Env.getCtx(), printInfo, null);
}
if (null != arc) {
arc.setBinaryData(data);
arc.setAD_Process_ID(processInfo.getAD_Process_ID());
arc.setRecord_ID(processInfo.getRecord_ID());
arc.setName(processInfo.getTitle());
success = arc.save();
}
}
if (success) {
FDialog.info(0, this, Msg.getMsg(ctx, "ArchiveSuccess", new Object[] { arc.getName() }));
log.log(Level.FINE, arc.getName() + " Archived Into " + arc.getAD_Archive_ID());
archive.setDisabled(Boolean.TRUE);
} else {
throw new AdempiereException("ArchiveError");
}
}
use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ArchiveEngine method archive.
/**
* Get/Create Archive.
* @param layout layout
* @param info print info
* @return existing document or newly created if Client enabled archiving.
* Will return NULL if archiving not enabled
*/
public byte[] archive(LayoutEngine layout, PrintInfo info) {
// Do we need to Archive ?
MClient client = MClient.get(layout.getCtx());
String aaClient = client.getAutoArchive();
// role.getAutoArchive(); // TODO
String aaRole = null;
String aa = aaClient;
if (aa == null)
aa = MClient.AUTOARCHIVE_None;
if (aaRole != null) {
if (aaRole.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
else if (aaRole.equals(MClient.AUTOARCHIVE_Documents) && !aaClient.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
}
// Mothing to Archive
if (aa.equals(MClient.AUTOARCHIVE_None))
return null;
// Archive External only
if (aa.equals(MClient.AUTOARCHIVE_ExternalDocuments)) {
if (info.isReport())
return null;
}
// Archive Documents only
if (aa.equals(MClient.AUTOARCHIVE_Documents)) {
if (info.isReport())
return null;
}
// Create Printable
// No Copy
byte[] data = Document.getPDFAsArray(layout.getPageable(false));
if (data == null)
return null;
// TODO to be done async
MArchive archive = new MArchive(layout.getCtx(), info, null);
archive.setBinaryData(data);
archive.saveEx();
return data;
}
Aggregations