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