Search in sources :

Example 16 with TableRecordReference

use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.

the class ADProcessPostProcessService method invalidateDocumentsAndViews.

private void invalidateDocumentsAndViews(final ViewId viewId, final ProcessExecutionResult processExecutionResult) {
    final Supplier<IView> viewSupplier = Suppliers.memoize(() -> {
        if (viewId == null) {
            return null;
        }
        final IView view = viewsRepo.getViewIfExists(viewId);
        if (view == null) {
            logger.warn("No view found for {}. View invalidation will be skipped for {}", viewId, processExecutionResult);
        }
        return view;
    });
    // 
    // Refresh all
    boolean viewInvalidateAllCalled = false;
    if (processExecutionResult.isRefreshAllAfterExecution() && viewSupplier.get() != null) {
        viewSupplier.get().invalidateAll();
        viewInvalidateAllCalled = true;
    }
    // 
    // Refresh required document
    final TableRecordReference recordToRefresh = processExecutionResult.getRecordToRefreshAfterExecution();
    if (recordToRefresh != null) {
        documentsCollection.invalidateDocumentByRecordId(recordToRefresh.getTableName(), recordToRefresh.getRecord_ID());
        if (!viewInvalidateAllCalled && viewSupplier.get() != null) {
            viewSupplier.get().notifyRecordsChanged(ImmutableSet.of(recordToRefresh));
        }
    }
}
Also used : IView(de.metas.ui.web.view.IView) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference)

Example 17 with TableRecordReference

use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_IssueReceipt_Launcher method doIt.

@Override
protected String doIt() throws Exception {
    final TableRecordReference ppOrderRef = TableRecordReference.of(I_PP_Order.Table_Name, getRecord_ID());
    getResult().setRecordToOpen(ppOrderRef, PPOrderConstants.AD_WINDOW_ID_IssueReceipt.toInt(), OpenTarget.GridView);
    return MSG_OK;
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference)

Example 18 with TableRecordReference

use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.

the class PickingTerminalViewInvalidationAdvisor method extractShipmentScheduleIds.

private Set<Integer> extractShipmentScheduleIds(final Set<TableRecordReference> recordRefs) {
    if (recordRefs.isEmpty()) {
        return ImmutableSet.of();
    }
    final Set<Integer> shipmentScheduleIds = new HashSet<>();
    final Set<Integer> pickingCandidateIds = new HashSet<>();
    for (TableRecordReference recordRef : recordRefs) {
        final String tableName = recordRef.getTableName();
        if (I_M_ShipmentSchedule.Table_Name.equals(tableName)) {
            shipmentScheduleIds.add(recordRef.getRecord_ID());
        } else if (I_M_Picking_Candidate.Table_Name.equals(tableName)) {
            pickingCandidateIds.add(recordRef.getRecord_ID());
        }
    }
    if (!pickingCandidateIds.isEmpty()) {
        shipmentScheduleIds.addAll(pickingCandidateRepository.retrieveShipmentScheduleIdsForPickingCandidateIds(pickingCandidateIds));
    }
    return shipmentScheduleIds;
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) HashSet(java.util.HashSet)

Example 19 with TableRecordReference

use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.

the class DebugRestController method postEvent.

@RequestMapping(value = "/eventBus/postEvent", method = RequestMethod.GET)
public void postEvent(// 
@RequestParam(name = "topicName", defaultValue = "de.metas.event.GeneralNotifications") final String topicName, // 
@RequestParam(name = "message", defaultValue = "test message") final String message, // 
@RequestParam(name = "toUserId", defaultValue = "-1") final int toUserId, // 
@RequestParam(name = "important", defaultValue = "false") final boolean important, // 
@RequestParam(name = "targetType", required = false) final String targetTypeStr, // 
@RequestParam(name = "targetDocumentType", required = false, defaultValue = "143") final String targetDocumentType, // 
@RequestParam(name = "targetDocumentId", required = false) final String targetDocumentId) {
    final Topic topic = Topic.builder().name(topicName).type(Type.LOCAL).build();
    final Builder eventBuilder = Event.builder().setSummary("summary").setDetailPlain(message).putProperty(UserNotificationRepository.EVENT_PARAM_Important, important);
    if (toUserId > 0) {
        eventBuilder.addRecipient_User_ID(toUserId);
    }
    final TargetType targetType = Check.isEmpty(targetTypeStr) ? null : TargetType.forJsonValue(targetTypeStr);
    if (targetType == TargetType.Window) {
        final String targetTableName = documentCollection.getDocumentDescriptorFactory().getDocumentDescriptor(WindowId.fromJson(targetDocumentType)).getEntityDescriptor().getTableName();
        final TableRecordReference targetRecord = TableRecordReference.of(targetTableName, Integer.parseInt(targetDocumentId));
        eventBuilder.setRecord(targetRecord);
    }
    final Event event = eventBuilder.build();
    Services.get(IEventBusFactory.class).getEventBus(topic).postEvent(event);
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) Builder(de.metas.event.Event.Builder) TargetType(de.metas.ui.web.notification.UserNotification.TargetType) Event(de.metas.event.Event) Topic(de.metas.event.Topic) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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