use of de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue in project metasfresh-webui-api by metasfresh.
the class ProductLookupDescriptor method createLookupValuesFromAvailableStockGroups.
private LookupValuesList createLookupValuesFromAvailableStockGroups(@NonNull final LookupValuesList initialLookupValues, @NonNull final List<Group> availableStockGroups) {
final boolean addOnlyPositiveATP = addOnlyPositiveATP();
final List<LookupValue> explodedProductValues = new ArrayList<>();
for (final Group availableStockGroup : availableStockGroups) {
if (addOnlyPositiveATP && availableStockGroup.getQty().signum() <= 0) {
continue;
}
final int productId = availableStockGroup.getProductId();
final LookupValue productLookupValue = initialLookupValues.getById(productId);
final ITranslatableString displayName = createDisplayName(productLookupValue.getDisplayNameTrl(), availableStockGroup);
final ImmutableMap<String, Object> attributeMap = availableStockGroup.getLookupAttributesMap();
final IntegerLookupValue integerLookupValue = IntegerLookupValue.builder().id(productId).displayName(displayName).attribute(ATTRIBUTE_ASI, attributeMap).build();
explodedProductValues.add(integerLookupValue);
}
if (explodedProductValues.isEmpty()) {
// fallback
return initialLookupValues;
}
return LookupValuesList.fromCollection(explodedProductValues);
}
use of de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue in project metasfresh-webui-api by metasfresh.
the class ASIDocument method complete.
IntegerLookupValue complete() {
assertNotCompleted();
final I_M_AttributeSetInstance asiRecord = createM_AttributeSetInstance(this);
final IntegerLookupValue lookupValue = IntegerLookupValue.of(asiRecord.getM_AttributeSetInstance_ID(), asiRecord.getDescription());
completed = true;
return lookupValue;
}
use of de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue in project metasfresh-webui-api by metasfresh.
the class MailRestController method createNewEmail.
@PostMapping()
@ApiOperation("Creates a new email")
public JSONEmail createNewEmail(@RequestBody final JSONEmailRequest request) {
userSession.assertLoggedIn();
final int adUserId = userSession.getAD_User_ID();
Services.get(IUserBL.class).assertCanSendEMail(adUserId);
final IntegerLookupValue from = IntegerLookupValue.of(adUserId, userSession.getUserFullname() + " <" + userSession.getUserEmail() + "> ");
final DocumentPath contextDocumentPath = JSONDocumentPath.toDocumentPathOrNull(request.getDocumentPath());
final BoilerPlateContext attributes = documentCollection.createBoilerPlateContext(contextDocumentPath);
final Integer toUserId = attributes.getAD_User_ID();
final LookupValue to = mailRepo.getToByUserId(toUserId);
final String emailId = mailRepo.createNewEmail(adUserId, from, to, contextDocumentPath).getEmailId();
if (contextDocumentPath != null) {
try {
final DocumentPrint contextDocumentPrint = documentCollection.createDocumentPrint(contextDocumentPath);
attachFile(emailId, () -> mailAttachmentsRepo.createAttachment(emailId, contextDocumentPrint.getFilename(), contextDocumentPrint.getReportData()));
} catch (final Exception ex) {
logger.debug("Failed creating attachment from document print of {}", contextDocumentPath, ex);
}
}
return JSONEmail.of(mailRepo.getEmail(emailId));
}
use of de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue in project metasfresh-webui-api by metasfresh.
the class HuTraceQueryCreator method updateHuTrxLineIdFromParameter.
private static HUTraceEventQuery updateHuTrxLineIdFromParameter(@NonNull final HUTraceEventQuery query, @NonNull final DocumentFilterParam parameter) {
errorIfQueryValueGreaterThanZero("TopLevelHuId", query.getHuTrxLineId(), query);
final IntegerLookupValue value = (IntegerLookupValue) parameter.getValue();
return query.withHuTrxLineId(value.getIdAsInt());
}
use of de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformParametersFiller method getM_HU_PI_Item_IDs.
public LookupValuesList getM_HU_PI_Item_IDs() {
final ActionType actionType = getActionType();
if (actionType != ActionType.TU_To_NewLUs) {
return LookupValuesList.EMPTY;
}
final HUEditorRow tuRow = getSelectedRow();
final I_M_HU tuHU = tuRow.getM_HU();
final I_M_HU_PI_Version effectivePIVersion = handlingUnitsBL.getEffectivePIVersion(tuHU);
Check.errorIf(effectivePIVersion == null, "tuHU is inconsistent; hu={}", tuHU);
final List<I_M_HU_PI_Item> luPIItems = handlingUnitsDAO.retrieveParentPIItemsForParentPI(effectivePIVersion.getM_HU_PI(), null, tuHU.getC_BPartner());
return luPIItems.stream().filter(luPIItem -> luPIItem.getM_HU_PI_Version().isCurrent() && luPIItem.getM_HU_PI_Version().isActive() && luPIItem.getM_HU_PI_Version().getM_HU_PI().isActive()).map(luPIItem -> IntegerLookupValue.of(luPIItem.getM_HU_PI_Item_ID(), WEBUI_ProcessHelper.buildHUPIItemString(luPIItem))).sorted(Comparator.comparing(IntegerLookupValue::getDisplayName)).collect(LookupValuesList.collect());
}
Aggregations