use of de.metas.ui.web.window.model.lookup.LookupDataSource in project metasfresh-webui-api by metasfresh.
the class DocumentField method getValueAsJsonObject.
@Override
public Object getValueAsJsonObject(final String adLanguage) {
Object value = getValue();
if (value == null) {
return null;
}
//
// If we are dealing with a lookup value, make, sure it's translated (see https://github.com/metasfresh/metasfresh-webui-api/issues/311 )
final LookupDataSource lookupDataSource = getLookupDataSourceOrNull();
if (lookupDataSource != null && value instanceof LookupValue) {
final LookupValue lookupValue = (LookupValue) value;
final ITranslatableString displayNameTrl = lookupValue.getDisplayNameTrl();
if (!displayNameTrl.isTranslatedTo(adLanguage)) {
final LookupValue lookupValueNew = lookupDataSource.findById(lookupValue.getId());
value = lookupValueNew;
}
}
return Values.valueToJsonObject(value);
}
use of de.metas.ui.web.window.model.lookup.LookupDataSource in project metasfresh-webui-api by metasfresh.
the class DocumentField method getLookupValues.
@Override
public LookupValuesList getLookupValues() {
final LookupDataSource lookupDataSource = getLookupDataSource();
final Evaluatee ctx = getDocument().asEvaluatee();
final LookupValuesList values = lookupDataSource.findEntities(ctx);
lookupValuesStaled = false;
return values == null ? LookupValuesList.EMPTY : values;
}
use of de.metas.ui.web.window.model.lookup.LookupDataSource 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.model.lookup.LookupDataSource 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.model.lookup.LookupDataSource in project metasfresh-webui-api by metasfresh.
the class DocumentField method getLookupValuesForQuery.
@Override
public LookupValuesList getLookupValuesForQuery(final String query) {
final LookupDataSource lookupDataSource = getLookupDataSource();
final Evaluatee ctx = getDocument().asEvaluatee();
final LookupValuesList values = lookupDataSource.findEntities(ctx, query);
lookupValuesStaled = false;
return values;
}
Aggregations