use of de.metas.ui.web.window.datatypes.LookupValuesList in project metasfresh-webui-api by metasfresh.
the class MailRestController method changeEmail.
private void changeEmail(final WebuiEmail email, final WebuiEmailBuilder newEmailBuilder, final JSONDocumentChangedEvent event) {
if (!event.isReplace()) {
throw new AdempiereException("Unsupported event").setParameter("event", event);
}
final String fieldName = event.getPath();
if (PATCH_FIELD_To.equals(fieldName)) {
@SuppressWarnings("unchecked") final List<Object> jsonTo = (List<Object>) event.getValue();
@SuppressWarnings("unchecked") final LookupValuesList to = jsonTo.stream().map(mapObj -> (Map<String, Object>) mapObj).map(map -> JSONLookupValue.integerLookupValueFromJsonMap(map)).collect(LookupValuesList.collect());
newEmailBuilder.to(to);
} else if (PATCH_FIELD_Subject.equals(fieldName)) {
final String subject = (String) event.getValue();
newEmailBuilder.subject(subject);
} else if (PATCH_FIELD_Message.equals(fieldName)) {
final String message = (String) event.getValue();
newEmailBuilder.message(message);
} else if (PATCH_FIELD_Attachments.equals(fieldName)) {
@SuppressWarnings("unchecked") final List<Object> jsonAttachments = (List<Object>) event.getValue();
@SuppressWarnings("unchecked") final LookupValuesList attachments = jsonAttachments.stream().map(mapObj -> (Map<String, Object>) mapObj).map(map -> JSONLookupValue.stringLookupValueFromJsonMap(map)).collect(LookupValuesList.collect());
newEmailBuilder.attachments(attachments);
} else if (PATCH_FIELD_TemplateId.equals(fieldName)) {
@SuppressWarnings("unchecked") final LookupValue templateId = JSONLookupValue.integerLookupValueFromJsonMap((Map<String, Object>) event.getValue());
applyTemplate(email, newEmailBuilder, 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.LookupValuesList in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformParametersFiller method getTUsLookupValues_All.
private LookupValuesList getTUsLookupValues_All(final LookupDataSourceContext context) {
final ActionType actionType = getActionType();
if (actionType == ActionType.CU_To_ExistingTU) {
// TODO: cache the descriptor
// TODO: filter by TUs
// TODO: search by barcode too
final LookupDescriptor lookupDescriptor = SqlLookupDescriptor.builder().setCtxTableName(// ctxTableName
null).setCtxColumnName("M_HU_ID").setDisplayType(DisplayType.Search).buildForDefaultScope();
LookupDataSource dataSource = LookupDataSourceFactory.instance.getLookupDataSource(lookupDescriptor);
final LookupValuesList result = dataSource.findEntities(context, context.getFilter(), context.getOffset(0), context.getLimit(10));
return result;
}
return LookupValuesList.EMPTY;
}
use of de.metas.ui.web.window.datatypes.LookupValuesList in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformParametersFiller method getLUsLookupValues_All.
private LookupValuesList getLUsLookupValues_All(final LookupDataSourceContext context) {
final ActionType actionType = getActionType();
if (actionType == ActionType.TU_To_ExistingLU) {
// TODO: cache the descriptor
// TODO: filter by LUs
// TODO: search by barcode too
final LookupDescriptor lookupDescriptor = SqlLookupDescriptor.builder().setCtxTableName(// ctxTableName
null).setCtxColumnName("M_HU_ID").setDisplayType(DisplayType.Search).buildForDefaultScope();
LookupDataSource dataSource = LookupDataSourceFactory.instance.getLookupDataSource(lookupDescriptor);
final LookupValuesList result = dataSource.findEntities(context, context.getFilter(), context.getOffset(0), context.getLimit(10));
return result;
} else {
return LookupValuesList.EMPTY;
}
}
use of de.metas.ui.web.window.datatypes.LookupValuesList in project metasfresh-webui-api by metasfresh.
the class GenericSqlLookupDataSourceFetcher method retrieveEntities.
/**
* @param evalCtx
* @return lookup values list
* @see #getRetrieveEntriesParameters()
*/
@Override
public LookupValuesList retrieveEntities(final LookupDataSourceContext evalCtx) {
final String sqlForFetching = sqlForFetchingExpression.evaluate(evalCtx, OnVariableNotFound.Fail);
final String adLanguage = isTranslatable ? evalCtx.getAD_Language() : null;
try (final SQLNamePairIterator data = new SQLNamePairIterator(sqlForFetching, numericKey, entityTypeIndex)) {
Map<String, String> debugProperties = null;
if (WindowConstants.isProtocolDebugging()) {
debugProperties = new LinkedHashMap<>();
debugProperties.put("debug-sql", sqlForFetching);
debugProperties.put("debug-params", evalCtx.toString());
}
final LookupValuesList values = data.fetchAll().stream().filter(evalCtx::acceptItem).map(namePair -> LookupValue.fromNamePair(namePair, adLanguage)).collect(LookupValuesList.collect(debugProperties));
logger.trace("Returning values={} (executed sql: {})", values, sqlForFetching);
return values;
}
}
use of de.metas.ui.web.window.datatypes.LookupValuesList in project metasfresh-webui-api by metasfresh.
the class FullyCachedLookupDataSource method findById.
@Override
public LookupValue findById(final Object idObj) {
final Object idNormalized = LookupValue.normalizeId(idObj, fetcher.isNumericKey());
if (idNormalized == null) {
return null;
}
final LookupValuesList partition = getLookupValuesList(Evaluatees.empty());
return partition.getById(idNormalized);
}
Aggregations