use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class PackageableRowsData method streamDocumentIdsToInvalidate.
@Override
public Stream<DocumentId> streamDocumentIdsToInvalidate(final TableRecordReference recordRef) {
final String tableName = recordRef.getTableName();
if (I_M_ShipmentSchedule.Table_Name.equals(tableName)) {
final int shipmentScheduleId = recordRef.getRecord_ID();
final TableRecordReference recordRefEffective = PackageableRow.createTableRecordReferenceFromShipmentScheduleId(shipmentScheduleId);
return initialDocumentIdsByRecordRef.get(recordRefEffective).stream();
} else {
return Stream.empty();
}
}
use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class LetterRestController method complete0.
private final WebuiLetter complete0(final WebuiLetter letter) {
lettersRepo.createC_Letter(letter);
//
// Create the printable letter
final byte[] pdfData = createPDFData(letter);
final File pdfFile = createFile(pdfData);
//
// create the Boilerplate context
final BoilerPlateContext context = documentCollection.createBoilerPlateContext(letter.getContextDocumentPath());
//
// Create the request
final TableRecordReference recordRef = documentCollection.getTableRecordReference(letter.getContextDocumentPath());
MADBoilerPlate.createRequest(pdfFile, recordRef.getAD_Table_ID(), recordRef.getRecord_ID(), context);
return letter.toBuilder().processed(true).temporaryPDFData(pdfData).build();
}
use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class DocumentCollection method duplicateDocumentInTrx.
private DocumentPath duplicateDocumentInTrx(final DocumentPath fromDocumentPath) {
// NOTE: assume it's already running in transaction
final TableRecordReference fromRecordRef = getTableRecordReference(fromDocumentPath);
final Object fromModel = fromRecordRef.getModel(PlainContextAware.newWithThreadInheritedTrx());
final String tableName = InterfaceWrapperHelper.getModelTableName(fromModel);
final PO fromPO = InterfaceWrapperHelper.getPO(fromModel);
final PO toPO = TableModelLoader.instance.newPO(Env.getCtx(), tableName, ITrx.TRXNAME_ThreadInherited);
// set "getValueToCopy" advisor
toPO.setDynAttribute(PO.DYNATTR_CopyRecordSupport, CopyRecordFactory.getCopyRecordSupport(tableName));
PO.copyValues(fromPO, toPO, true);
InterfaceWrapperHelper.save(toPO);
final CopyRecordSupport childCRS = CopyRecordFactory.getCopyRecordSupport(tableName);
childCRS.setAD_Window_ID(fromDocumentPath.getAD_Window_ID(-1));
childCRS.setParentPO(toPO);
childCRS.setBase(true);
childCRS.copyRecord(fromPO, ITrx.TRXNAME_ThreadInherited);
final DocumentPath toDocumentPath = DocumentPath.rootDocumentPath(fromDocumentPath.getWindowId(), DocumentId.of(toPO.get_ID()));
return toDocumentPath;
}
use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class DocumentCollection method createDocumentPrint.
public DocumentPrint createDocumentPrint(final DocumentPath documentPath) {
final Document document = getDocumentReadonly(documentPath);
final int windowNo = document.getWindowNo();
final DocumentEntityDescriptor entityDescriptor = document.getEntityDescriptor();
final int printProcessId = entityDescriptor.getPrintProcessId();
final TableRecordReference recordRef = getTableRecordReference(documentPath);
final ProcessExecutionResult processExecutionResult = ProcessInfo.builder().setCtx(Env.getCtx()).setAD_Process_ID(printProcessId).setWindowNo(// important: required for ProcessInfo.findReportingLanguage
windowNo).setRecord(recordRef).setPrintPreview(true).setJRDesiredOutputType(OutputType.PDF).buildAndPrepareExecution().onErrorThrowException().switchContextWhenRunning().executeSync().getResult();
return DocumentPrint.builder().filename(processExecutionResult.getReportFilename()).reportContentType(processExecutionResult.getReportContentType()).reportData(processExecutionResult.getReportData()).build();
}
use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class DocumentAttachmentsRestController method getDocumentAttachments.
private DocumentAttachments getDocumentAttachments(final String windowIdStr, final String documentId) {
final DocumentPath documentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), documentId);
final TableRecordReference recordRef = documentDescriptorFactory.getTableRecordReference(documentPath);
return DocumentAttachments.builder().documentPath(documentPath).recordRef(recordRef).entityDescriptor(documentDescriptorFactory.getDocumentEntityDescriptor(documentPath)).websocketPublisher(websocketPublisher).build();
}
Aggregations