Search in sources :

Example 6 with TableRecordReference

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();
    }
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) ToString(lombok.ToString)

Example 7 with TableRecordReference

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();
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) BoilerPlateContext(de.metas.letters.model.MADBoilerPlate.BoilerPlateContext) File(java.io.File)

Example 8 with TableRecordReference

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;
}
Also used : CopyRecordSupport(org.adempiere.model.CopyRecordSupport) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) PO(org.compiere.model.PO)

Example 9 with TableRecordReference

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();
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) SourceDocument(de.metas.letters.model.MADBoilerPlate.SourceDocument) ProcessExecutionResult(de.metas.process.ProcessExecutionResult)

Example 10 with TableRecordReference

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();
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Aggregations

TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)19 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)6 WindowId (de.metas.ui.web.window.datatypes.WindowId)5 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)4 IView (de.metas.ui.web.view.IView)3 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)3 AdempiereException (org.adempiere.exceptions.AdempiereException)3 ProcessExecutionResult (de.metas.process.ProcessExecutionResult)2 ViewId (de.metas.ui.web.view.ViewId)2 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 List (java.util.List)2 Set (java.util.Set)2 NonNull (lombok.NonNull)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 Suppliers (com.google.common.base.Suppliers)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 I_C_Order (de.metas.adempiere.model.I_C_Order)1 Event (de.metas.event.Event)1