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);
}
}
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());
}
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);
}
}
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();
}
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);
}
}
Aggregations