Search in sources :

Example 46 with NonNull

use of lombok.NonNull in project metasfresh-webui-api by metasfresh.

the class MailRestController method attachFile.

private WebuiEmail attachFile(final String emailId, final Supplier<LookupValue> attachmentProducer) {
    // Ask the producer to create the attachment
    @NonNull final LookupValue attachment = attachmentProducer.get();
    try {
        final WebuiEmailChangeResult result = changeEmail(emailId, emailOld -> {
            final LookupValuesList attachmentsOld = emailOld.getAttachments();
            final LookupValuesList attachmentsNew = attachmentsOld.addIfAbsent(attachment);
            return emailOld.toBuilder().attachments(attachmentsNew).build();
        });
        return result.getEmail();
    } catch (final Throwable ex) {
        mailAttachmentsRepo.deleteAttachment(emailId, attachment);
        throw AdempiereException.wrapIfNeeded(ex);
    }
}
Also used : NonNull(lombok.NonNull) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 47 with NonNull

use of lombok.NonNull in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_Pick_ParametersFiller method getPickingSlotValues.

public LookupValuesList getPickingSlotValues(@NonNull final LookupDataSourceContext context) {
    if (shipmentScheduleId <= 0) {
        return LookupValuesList.EMPTY;
    }
    final IShipmentScheduleEffectiveBL shipmentScheduleEffectiveBL = Services.get(IShipmentScheduleEffectiveBL.class);
    final I_M_ShipmentSchedule shipmentSchedule = load(shipmentScheduleId, I_M_ShipmentSchedule.class);
    final PickingSlotQuery pickingSlotQuery = PickingSlotQuery.builder().availableForBPartnerId(shipmentScheduleEffectiveBL.getC_BP_Location_ID(shipmentSchedule)).availableForBPartnerLocationId(shipmentScheduleEffectiveBL.getC_BP_Location_ID(shipmentSchedule)).build();
    final List<I_M_PickingSlot> availablePickingSlots = Services.get(IPickingSlotDAO.class).retrievePickingSlots(pickingSlotQuery);
    return availablePickingSlots.stream().map(pickingSlot -> IntegerLookupValue.of(pickingSlot.getM_PickingSlot_ID(), createPickingSlotLabel(pickingSlot))).collect(LookupValuesList.collect());
}
Also used : IShipmentSchedulePA(de.metas.inoutcandidate.api.IShipmentSchedulePA) LookupDataSourceFactory(de.metas.ui.web.window.model.lookup.LookupDataSourceFactory) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) I_M_ShipmentSchedule(de.metas.inoutcandidate.model.I_M_ShipmentSchedule) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) DB(org.compiere.util.DB) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) ImmutableList(com.google.common.collect.ImmutableList) DisplayType(org.compiere.util.DisplayType) I_M_PickingSlot(de.metas.picking.model.I_M_PickingSlot) IPickingSlotDAO(de.metas.picking.api.IPickingSlotDAO) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_M_HU(de.metas.handlingunits.model.I_M_HU) IProcessDefaultParameter(de.metas.process.IProcessDefaultParameter) I_C_BPartner(org.compiere.model.I_C_BPartner) IShipmentScheduleEffectiveBL(de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) NonNull(lombok.NonNull) IHUContextFactory(de.metas.handlingunits.IHUContextFactory) Services(org.adempiere.util.Services) List(java.util.List) Builder(lombok.Builder) AdempiereException(org.adempiere.exceptions.AdempiereException) IValidationRuleFactory(org.adempiere.ad.validationRule.IValidationRuleFactory) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) PickingSlotQuery(de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery) IValidationRule(org.adempiere.ad.validationRule.IValidationRule) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage) I_M_PickingSlot(de.metas.picking.model.I_M_PickingSlot) PickingSlotQuery(de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery) IPickingSlotDAO(de.metas.picking.api.IPickingSlotDAO) IShipmentScheduleEffectiveBL(de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL) I_M_ShipmentSchedule(de.metas.inoutcandidate.model.I_M_ShipmentSchedule)

Example 48 with NonNull

use of lombok.NonNull in project metasfresh-webui-api by metasfresh.

the class DocumentCollection method getDocumentPath.

/**
 * Retrieves document path for given ZoomInto info.
 *
 * @param zoomIntoInfo
 */
public DocumentPath getDocumentPath(@NonNull final DocumentZoomIntoInfo zoomIntoInfo) {
    if (!zoomIntoInfo.isRecordIdPresent()) {
        throw new IllegalArgumentException("recordId must be set in " + zoomIntoInfo);
    }
    // 
    // Find the root window ID
    final WindowId zoomIntoWindowIdEffective = getWindowId(zoomIntoInfo);
    final DocumentEntityDescriptor rootEntityDescriptor = getDocumentEntityDescriptor(zoomIntoWindowIdEffective);
    final String zoomIntoTableName = zoomIntoInfo.getTableName();
    // (i.e. root descriptor's table is matching record's table)
    if (Objects.equals(rootEntityDescriptor.getTableName(), zoomIntoTableName)) {
        final DocumentId rootDocumentId = DocumentId.of(zoomIntoInfo.getRecordId());
        return DocumentPath.rootDocumentPath(zoomIntoWindowIdEffective, rootDocumentId);
    } else // 
    // We are dealing with an included document
    {
        // Search the root descriptor for any child entity descriptor which would match record's TableName
        final List<DocumentEntityDescriptor> childEntityDescriptors = rootEntityDescriptor.getIncludedEntities().stream().filter(includedEntityDescriptor -> Objects.equals(includedEntityDescriptor.getTableName(), zoomIntoTableName)).collect(ImmutableList.toImmutableList());
        if (childEntityDescriptors.isEmpty()) {
            throw new EntityNotFoundException("Cannot find the detail tab to zoom into").setParameter("zoomIntoInfo", zoomIntoInfo).setParameter("zoomIntoWindowId", zoomIntoWindowIdEffective).setParameter("rootEntityDescriptor", rootEntityDescriptor);
        } else if (childEntityDescriptors.size() > 1) {
            logger.warn("More then one child descriptors matched our root descriptor. Picking the fist one. \nRoot descriptor: {} \nChild descriptors: {}", rootEntityDescriptor, childEntityDescriptors);
        }
        // 
        final DocumentEntityDescriptor childEntityDescriptor = childEntityDescriptors.get(0);
        // Find the root DocumentId
        final DocumentId rowId = DocumentId.of(zoomIntoInfo.getRecordId());
        final DocumentId rootDocumentId = DocumentQuery.ofRecordId(childEntityDescriptor, rowId).retrieveParentDocumentId(rootEntityDescriptor);
        // 
        return DocumentPath.includedDocumentPath(zoomIntoWindowIdEffective, rootDocumentId, childEntityDescriptor.getDetailId(), rowId);
    }
}
Also used : DocumentPermissionsHelper(de.metas.ui.web.window.controller.DocumentPermissionsHelper) DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) ITrx(org.adempiere.ad.trx.api.ITrx) Env(org.compiere.util.Env) Autowired(org.springframework.beans.factory.annotation.Autowired) OutputType(de.metas.adempiere.report.jasper.OutputType) SourceDocument(de.metas.letters.model.MADBoilerPlate.SourceDocument) Evaluatee(org.compiere.util.Evaluatee) TableModelLoader(org.adempiere.ad.persistence.TableModelLoader) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) DocumentWebsocketPublisher(de.metas.ui.web.window.events.DocumentWebsocketPublisher) CopyRecordSupport(org.adempiere.model.CopyRecordSupport) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) RecordZoomWindowFinder(org.adempiere.model.RecordZoomWindowFinder) ImmutableSet(com.google.common.collect.ImmutableSet) WindowConstants(de.metas.ui.web.window.WindowConstants) NonNull(lombok.NonNull) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DocumentDescriptor(de.metas.ui.web.window.descriptor.DocumentDescriptor) Set(java.util.Set) Objects(java.util.Objects) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) UserSession(de.metas.ui.web.session.UserSession) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Builder(lombok.Builder) CopyRecordFactory(org.adempiere.model.CopyRecordFactory) CacheBuilder(com.google.common.cache.CacheBuilder) DocumentType(de.metas.ui.web.window.datatypes.DocumentType) LogManager(de.metas.logging.LogManager) ProcessInfo(de.metas.process.ProcessInfo) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) ProcessExecutionResult(de.metas.process.ProcessExecutionResult) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) InvalidDocumentPathException(de.metas.ui.web.window.exceptions.InvalidDocumentPathException) Function(java.util.function.Function) PlainContextAware(org.adempiere.model.PlainContextAware) DocumentNotFoundException(de.metas.ui.web.window.exceptions.DocumentNotFoundException) Value(lombok.Value) CopyMode(de.metas.ui.web.window.model.Document.CopyMode) ImmutableList(com.google.common.collect.ImmutableList) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) Nullable(javax.annotation.Nullable) OnVariableNotFound(org.adempiere.ad.expression.api.IExpressionEvaluator.OnVariableNotFound) MADBoilerPlate(de.metas.letters.model.MADBoilerPlate) Logger(org.slf4j.Logger) Evaluatees(org.compiere.util.Evaluatees) DocumentDescriptorFactory(de.metas.ui.web.window.descriptor.factory.DocumentDescriptorFactory) LogicExpressionResult(org.adempiere.ad.expression.api.LogicExpressionResult) MoreObjects(com.google.common.base.MoreObjects) WindowId(de.metas.ui.web.window.datatypes.WindowId) IAutoCloseable(org.adempiere.util.lang.IAutoCloseable) ExecutionException(java.util.concurrent.ExecutionException) BoilerPlateContext(de.metas.letters.model.MADBoilerPlate.BoilerPlateContext) Component(org.springframework.stereotype.Component) AdempiereException(org.adempiere.exceptions.AdempiereException) Check(org.adempiere.util.Check) Preconditions(com.google.common.base.Preconditions) PO(org.compiere.model.PO) Cache(com.google.common.cache.Cache) AllArgsConstructor(lombok.AllArgsConstructor) Collections(java.util.Collections) Immutable(javax.annotation.concurrent.Immutable) WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Example 49 with NonNull

use of lombok.NonNull in project metasfresh-webui-api by metasfresh.

the class PPOrderLinesLoader method createForHUViewRecordRecursively.

private PPOrderLineRow createForHUViewRecordRecursively(@NonNull final I_PP_Order_Qty ppOrderQty, @NonNull final HUEditorRow huEditorRow, @Nullable final HUEditorRow parentHUEditorRow, final boolean readonly) {
    final Quantity quantity = computeQuantityForHuPPOrderLineRow(ppOrderQty, huEditorRow, parentHUEditorRow);
    final ImmutableList<PPOrderLineRow> includedRows = huEditorRow.getIncludedRows().stream().map(includedHUEditorRow -> createForHUViewRecordRecursively(ppOrderQty, includedHUEditorRow, huEditorRow, readonly)).collect(ImmutableList.toImmutableList());
    return PPOrderLineRow.builderForIssuedOrReceivedHU().rowId(huEditorRow.getId()).type(PPOrderLineType.ofHUEditorRowType(huEditorRow.getType())).ppOrderQty(ppOrderQty).processed(readonly || ppOrderQty.isProcessed()).attributesSupplier(huEditorRow.getAttributesSupplier()).code(huEditorRow.getValue()).product(huEditorRow.getProduct()).packingInfo(huEditorRow.getPackingInfo()).topLevelHU(huEditorRow.isTopLevel()).huStatus(huEditorRow.getHUStatus()).quantity(quantity).includedRows(includedRows).build();
}
Also used : I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) X_PP_Order_BOMLine(org.eevolution.model.X_PP_Order_BOMLine) GuavaCollectors(org.adempiere.util.GuavaCollectors) ListMultimap(com.google.common.collect.ListMultimap) IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) InterfaceWrapperHelper.loadOutOfTrx(org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx) I_PP_Order_Qty(de.metas.handlingunits.model.I_PP_Order_Qty) Function(java.util.function.Function) IPPOrderBOMDAO(de.metas.material.planning.pporder.IPPOrderBOMDAO) BigDecimal(java.math.BigDecimal) SqlHUEditorViewRepository(de.metas.ui.web.handlingunits.SqlHUEditorViewRepository) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) ImmutableList(com.google.common.collect.ImmutableList) Quantity(de.metas.quantity.Quantity) I_PP_Order(de.metas.handlingunits.model.I_PP_Order) HUPackingInfos(de.metas.ui.web.handlingunits.util.HUPackingInfos) Nullable(javax.annotation.Nullable) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) IHUPPOrderQtyDAO(de.metas.handlingunits.pporder.api.IHUPPOrderQtyDAO) MatchingSourceHusQuery(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery) Util(org.compiere.util.Util) IPPOrderBOMBL(de.metas.material.planning.pporder.IPPOrderBOMBL) ImmutableSet(com.google.common.collect.ImmutableSet) HUPackingInfoFormatter(de.metas.ui.web.handlingunits.util.HUPackingInfoFormatter) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) HUEditorViewRepository(de.metas.ui.web.handlingunits.HUEditorViewRepository) SourceHUsService(de.metas.handlingunits.sourcehu.SourceHUsService) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) WindowId(de.metas.ui.web.window.datatypes.WindowId) IHUPackingInfo(de.metas.ui.web.handlingunits.util.IHUPackingInfo) I_PP_Order_BOMLine(de.metas.handlingunits.model.I_PP_Order_BOMLine) ASIViewRowAttributesProvider(de.metas.ui.web.view.ASIViewRowAttributesProvider) Services(org.adempiere.util.Services) List(java.util.List) Builder(lombok.Builder) I_C_DocType(org.compiere.model.I_C_DocType) X_PP_Order(org.eevolution.model.X_PP_Order) Comparator(java.util.Comparator) HUEditorRowAttributesProvider(de.metas.ui.web.handlingunits.HUEditorRowAttributesProvider) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString) Quantity(de.metas.quantity.Quantity)

Example 50 with NonNull

use of lombok.NonNull in project metasfresh-webui-api by metasfresh.

the class SqlViewKeyColumnNamesMap method getSqlFilterByRowIds.

@Builder(builderMethodName = "prepareSqlFilterByRowIds", builderClassName = "SqlFilterByRowIdsBuilder")
private SqlAndParams getSqlFilterByRowIds(@NonNull final DocumentIdsSelection rowIds, final SqlViewRowIdsConverter rowIdsConverter, final String sqlColumnPrefix, final boolean useKeyColumnName, final boolean embedSqlParams) {
    if (rowIds.isEmpty()) {
        throw new AdempiereException("rowIds shall not be empty");
    }
    if (isSingleKey()) {
        final String selectionColumnName = useKeyColumnName ? getSingleKeyColumnName() : getSingleWebuiSelectionColumnName();
        final String keyColumnName = (sqlColumnPrefix != null ? sqlColumnPrefix : "") + selectionColumnName;
        final Set<Integer> recordIds = rowIdsConverter != null ? rowIdsConverter.convertToRecordIds(rowIds) : rowIds.toIntSet();
        final List<Object> sqlParams = embedSqlParams ? null : new ArrayList<>();
        final String sql = DB.buildSqlList(keyColumnName, recordIds, sqlParams);
        return SqlAndParams.of(sql, sqlParams != null ? sqlParams : ImmutableList.of());
    } else {
        final List<SqlAndParams> sqls = rowIds.toSet().stream().map(rowId -> getSqlFilterByRowId(rowId, sqlColumnPrefix, useKeyColumnName, embedSqlParams)).collect(ImmutableList.toImmutableList());
        return SqlAndParams.and(sqls);
    }
}
Also used : Singular(lombok.Singular) BiFunction(java.util.function.BiFunction) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Function(java.util.function.Function) I_T_WEBUI_ViewSelection(de.metas.ui.web.base.model.I_T_WEBUI_ViewSelection) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) DB(org.compiere.util.DB) ImmutableList(com.google.common.collect.ImmutableList) SqlEntityFieldBinding(de.metas.ui.web.window.descriptor.sql.SqlEntityFieldBinding) ResultSet(java.sql.ResultSet) Map(java.util.Map) PlainSqlEntityFieldBinding(de.metas.ui.web.window.descriptor.sql.PlainSqlEntityFieldBinding) ToString(lombok.ToString) Predicates(com.google.common.base.Predicates) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ImmutableMap(com.google.common.collect.ImmutableMap) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) DBException(org.adempiere.exceptions.DBException) List(java.util.List) Builder(lombok.Builder) AdempiereException(org.adempiere.exceptions.AdempiereException) Check(org.adempiere.util.Check) SqlDocumentQueryBuilder(de.metas.ui.web.window.model.sql.SqlDocumentQueryBuilder) AdempiereException(org.adempiere.exceptions.AdempiereException) ToString(lombok.ToString) Builder(lombok.Builder) SqlDocumentQueryBuilder(de.metas.ui.web.window.model.sql.SqlDocumentQueryBuilder)

Aggregations

NonNull (lombok.NonNull)52 List (java.util.List)31 Collectors (java.util.stream.Collectors)22 Map (java.util.Map)20 Slf4j (lombok.extern.slf4j.Slf4j)18 ArrayList (java.util.ArrayList)17 Collection (java.util.Collection)17 HashMap (java.util.HashMap)16 lombok.val (lombok.val)14 Collections (java.util.Collections)13 Duration (java.time.Duration)11 Nullable (javax.annotation.Nullable)11 TimeoutTimer (io.pravega.common.TimeoutTimer)10 Set (java.util.Set)10 CompletableFuture (java.util.concurrent.CompletableFuture)10 Function (java.util.function.Function)10 Futures (io.pravega.common.concurrent.Futures)9 Getter (lombok.Getter)9 Preconditions (com.google.common.base.Preconditions)8 Strings (com.google.common.base.Strings)8