Search in sources :

Example 1 with LookupDataSource

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

Example 2 with LookupDataSource

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;
}
Also used : LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) Evaluatee(org.compiere.util.Evaluatee)

Example 3 with LookupDataSource

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;
}
Also used : ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Example 4 with LookupDataSource

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;
    }
}
Also used : ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Example 5 with LookupDataSource

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;
}
Also used : LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) Evaluatee(org.compiere.util.Evaluatee)

Aggregations

LookupDataSource (de.metas.ui.web.window.model.lookup.LookupDataSource)6 LookupValuesList (de.metas.ui.web.window.datatypes.LookupValuesList)4 ActionType (de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType)2 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)2 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)2 Evaluatee (org.compiere.util.Evaluatee)2 ITranslatableString (de.metas.i18n.ITranslatableString)1 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)1 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)1