Search in sources :

Example 1 with IntegerLookupValue

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);
}
Also used : Group(de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group) ArrayList(java.util.ArrayList) ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) NumberTranslatableString(de.metas.i18n.NumberTranslatableString) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 2 with IntegerLookupValue

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;
}
Also used : I_M_AttributeSetInstance(org.compiere.model.I_M_AttributeSetInstance) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)

Example 3 with IntegerLookupValue

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));
}
Also used : IUserBL(org.adempiere.user.api.IUserBL) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) BoilerPlateContext(de.metas.letters.model.MADBoilerPlate.BoilerPlateContext) DocumentPrint(de.metas.ui.web.window.model.DocumentCollection.DocumentPrint) DocumentPrint(de.metas.ui.web.window.model.DocumentCollection.DocumentPrint) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) IOException(java.io.IOException) AdempiereException(org.adempiere.exceptions.AdempiereException) 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) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with IntegerLookupValue

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());
}
Also used : IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)

Example 5 with IntegerLookupValue

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());
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) LookupDataSourceFactory(de.metas.ui.web.window.model.lookup.LookupDataSourceFactory) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) Env(org.compiere.util.Env) HUEditorRowFilter(de.metas.ui.web.handlingunits.HUEditorRowFilter) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) I_AD_Process_Para(org.compiere.model.I_AD_Process_Para) HashSet(java.util.HashSet) ADRefListItem(org.adempiere.ad.service.IADReferenceDAO.ADRefListItem) Select(de.metas.ui.web.handlingunits.HUEditorRowFilter.Select) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) DisplayType(org.compiere.util.DisplayType) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) IADReferenceDAO(org.adempiere.ad.service.IADReferenceDAO) I_M_HU(de.metas.handlingunits.model.I_M_HU) Nullable(javax.annotation.Nullable) I_C_BPartner(org.compiere.model.I_C_BPartner) IADProcessDAO(de.metas.process.IADProcessDAO) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) HUTransformService(de.metas.handlingunits.allocation.transfer.HUTransformService) Services(org.adempiere.util.Services) List(java.util.List) WEBUI_ProcessHelper(de.metas.ui.web.handlingunits.util.WEBUI_ProcessHelper) StringLookupValue(de.metas.ui.web.window.datatypes.LookupValue.StringLookupValue) X_M_HU(de.metas.handlingunits.model.X_M_HU) Builder(lombok.Builder) Check(de.metas.printing.esb.base.util.Check) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) I_M_Product(de.metas.adempiere.model.I_M_Product) ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) Comparator(java.util.Comparator) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Aggregations

IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)10 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)5 StringLookupValue (de.metas.ui.web.window.datatypes.LookupValue.StringLookupValue)3 JSONLookupValue (de.metas.ui.web.window.datatypes.json.JSONLookupValue)3 ITranslatableString (de.metas.i18n.ITranslatableString)2 LookupValuesList (de.metas.ui.web.window.datatypes.LookupValuesList)2 Password (de.metas.ui.web.window.datatypes.Password)2 JSONDate (de.metas.ui.web.window.datatypes.json.JSONDate)2 Timestamp (java.sql.Timestamp)2 Map (java.util.Map)2 I_C_Postal (de.metas.adempiere.model.I_C_Postal)1 I_M_Product (de.metas.adempiere.model.I_M_Product)1 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 HUTransformService (de.metas.handlingunits.allocation.transfer.HUTransformService)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)1 I_M_HU_PI_Version (de.metas.handlingunits.model.I_M_HU_PI_Version)1 X_M_HU (de.metas.handlingunits.model.X_M_HU)1 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)1