Search in sources :

Example 11 with LookupValue

use of de.metas.ui.web.window.datatypes.LookupValue in project metasfresh-webui-api by metasfresh.

the class HuTraceQueryCreator method updateVhuIdFromParameter.

private static HUTraceEventQuery updateVhuIdFromParameter(@NonNull final HUTraceEventQuery query, @NonNull final DocumentFilterParam parameter) {
    errorIfQueryValueGreaterThanZero("VhuId", query.getVhuId(), query);
    final LookupValue value = (LookupValue) parameter.getValue();
    return query.withVhuId(value.getIdAsInt());
}
Also used : LookupValue(de.metas.ui.web.window.datatypes.LookupValue) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)

Example 12 with LookupValue

use of de.metas.ui.web.window.datatypes.LookupValue in project metasfresh-webui-api by metasfresh.

the class HuTraceQueryCreator method updateTopLevelHuIdFromParameter.

private static HUTraceEventQuery updateTopLevelHuIdFromParameter(@NonNull final HUTraceEventQuery query, @NonNull final DocumentFilterParam parameter) {
    errorIfQueryValueGreaterThanZero("TopLevelHuId", query.getTopLevelHuId(), query);
    final LookupValue value = (LookupValue) parameter.getValue();
    return query.withTopLevelHuId(value.getIdAsInt());
}
Also used : LookupValue(de.metas.ui.web.window.datatypes.LookupValue) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)

Example 13 with LookupValue

use of de.metas.ui.web.window.datatypes.LookupValue in project metasfresh-webui-api by metasfresh.

the class LookupDataSourceAdapter method findById.

@Override
public LookupValue findById(final Object idObj) {
    if (idObj == null) {
        return null;
    }
    // 
    // Normalize the ID to Integer/String
    final Object idNormalized = LookupValue.normalizeId(idObj, fetcher.isNumericKey());
    if (idNormalized == null) {
        return null;
    }
    // 
    // Build the validation context
    final LookupDataSourceContext evalCtx = fetcher.newContextForFetchingById(idNormalized).putFilterById(idNormalized).putShowInactive(true).build();
    // 
    // Get the lookup value
    final LookupValue lookupValue = fetcher.retrieveLookupValueById(evalCtx);
    if (lookupValue == LookupDataSourceFetcher.LOOKUPVALUE_NULL) {
        return null;
    }
    return lookupValue;
}
Also used : LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 14 with LookupValue

use of de.metas.ui.web.window.datatypes.LookupValue in project metasfresh-webui-api by metasfresh.

the class LetterRestController method changeLetter.

private void changeLetter(final WebuiLetter letter, final WebuiLetter.WebuiLetterBuilder newLetterBuilder, final JSONDocumentChangedEvent event) {
    if (!event.isReplace()) {
        throw new AdempiereException("Unsupported event").setParameter("event", event);
    }
    final String fieldName = event.getPath();
    if (PATCH_FIELD_Message.equals(fieldName)) {
        final String message = event.getValueAsString(null);
        newLetterBuilder.content(message);
    } else if (PATCH_FIELD_TemplateId.equals(fieldName)) {
        @SuppressWarnings("unchecked") final LookupValue templateId = JSONLookupValue.integerLookupValueFromJsonMap((Map<String, Object>) event.getValue());
        applyTemplate(letter, newLetterBuilder, templateId);
    } else {
        throw new AdempiereException("Unsupported event path").setParameter("event", event).setParameter("fieldName", fieldName).setParameter("availablePaths", PATCH_FIELD_ALL);
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) Map(java.util.Map) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 15 with LookupValue

use of de.metas.ui.web.window.datatypes.LookupValue 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)

Aggregations

LookupValue (de.metas.ui.web.window.datatypes.LookupValue)31 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)25 LookupValuesList (de.metas.ui.web.window.datatypes.LookupValuesList)7 JSONLookupValue (de.metas.ui.web.window.datatypes.json.JSONLookupValue)6 ITranslatableString (de.metas.i18n.ITranslatableString)5 AdempiereException (org.adempiere.exceptions.AdempiereException)4 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 IHUOrderBL (de.metas.handlingunits.order.api.IHUOrderBL)2 NumberTranslatableString (de.metas.i18n.NumberTranslatableString)2 BoilerPlateContext (de.metas.letters.model.MADBoilerPlate.BoilerPlateContext)2 ProcessInfoParameter (de.metas.process.ProcessInfoParameter)2 QuickInput (de.metas.ui.web.quickinput.QuickInput)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 StringLookupValue (de.metas.ui.web.window.datatypes.LookupValue.StringLookupValue)2 Password (de.metas.ui.web.window.datatypes.Password)2 JSONDate (de.metas.ui.web.window.datatypes.json.JSONDate)2 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)2 JSONLookupValuesList (de.metas.ui.web.window.datatypes.json.JSONLookupValuesList)2