Search in sources :

Example 1 with LookupValuesList

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

the class ProductLookupDescriptor method retrieveEntities.

@Override
public LookupValuesList retrieveEntities(final LookupDataSourceContext evalCtx) {
    final SqlParamsCollector sqlParams = SqlParamsCollector.newInstance();
    final String sql = buildSql(sqlParams, evalCtx);
    if (sql == null) {
        return LookupValuesList.EMPTY;
    }
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, ITrx.TRXNAME_None);
        DB.setParameters(pstmt, sqlParams.toList());
        rs = pstmt.executeQuery();
        final Map<Integer, LookupValue> valuesById = new LinkedHashMap<>();
        while (rs.next()) {
            final LookupValue value = loadLookupValue(rs);
            valuesById.putIfAbsent(value.getIdAsInt(), value);
        }
        final LookupValuesList unexplodedLookupValues = LookupValuesList.fromCollection(valuesById.values());
        final Date stockdateOrNull = getEffectiveStockDateOrNull(evalCtx);
        if (stockdateOrNull == null || availableToPromiseAdapter == null) {
            return unexplodedLookupValues;
        }
        return explodeRecordsWithStockQuantities(unexplodedLookupValues, stockdateOrNull);
    } catch (final SQLException ex) {
        throw new DBException(ex, sql, sqlParams.toList());
    } finally {
        DB.close(rs, pstmt);
    }
}
Also used : DBException(org.adempiere.exceptions.DBException) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) PreparedStatement(java.sql.PreparedStatement) ITranslatableString(de.metas.i18n.ITranslatableString) NumberTranslatableString(de.metas.i18n.NumberTranslatableString) SqlParamsCollector(de.metas.ui.web.document.filter.sql.SqlParamsCollector) Date(java.util.Date) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with LookupValuesList

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

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

the class PackingInfoProcessParams method getM_HU_PI_Item_Products.

/**
 * @return a list of PI item products that match the selected CU's product and partner, sorted by name.
 */
public LookupValuesList getM_HU_PI_Item_Products() {
    final I_M_HU_LUTU_Configuration defaultLUTUConfig = getDefaultLUTUConfig();
    final I_M_Product product = defaultLUTUConfig.getM_Product();
    final I_C_BPartner bPartner = defaultLUTUConfig.getC_BPartner();
    final boolean includeVirtualItem = !enforcePhysicalTU;
    final LookupValuesList huPIItemProducts = WEBUI_ProcessHelper.retrieveHUPIItemProducts(Env.getCtx(), product, bPartner, includeVirtualItem);
    return huPIItemProducts;
}
Also used : I_M_Product(org.compiere.model.I_M_Product) I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_C_BPartner(org.compiere.model.I_C_BPartner)

Example 4 with LookupValuesList

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

the class WebuiMailRepository method createNewEmail.

public WebuiEmail createNewEmail(final int ownerUserId, final LookupValue from, final LookupValue to, final DocumentPath contextDocumentPath) {
    Preconditions.checkArgument(ownerUserId >= 0, "ownerUserId >= 0");
    final String emailId = String.valueOf(nextEmailId.getAndIncrement());
    final LookupValuesList toList = LookupValuesList.fromNullable(to);
    final WebuiEmail email = WebuiEmail.builder().emailId(emailId).ownerUserId(ownerUserId).from(from).to(toList).contextDocumentPath(contextDocumentPath).build();
    emailsById.put(emailId, new WebuiEmailEntry(email));
    return email;
}
Also used : LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) ToString(lombok.ToString)

Example 5 with LookupValuesList

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

the class MailRestController method changeEmail.

private WebuiEmailChangeResult changeEmail(final String emailId, final UnaryOperator<WebuiEmail> emailModifier) {
    final WebuiEmailChangeResult result = mailRepo.changeEmail(emailId, emailOld -> {
        assertWritable(emailOld);
        return emailModifier.apply(emailOld);
    });
    // Delete the attachments which were removed from email
    final LookupValuesList attachmentsOld = result.getOriginalEmail().getAttachments();
    final LookupValuesList attachmentsNew = result.getEmail().getAttachments();
    final LookupValuesList attachmentsToRemove = attachmentsOld.removeAll(attachmentsNew);
    mailAttachmentsRepo.deleteAttachments(emailId, attachmentsToRemove);
    return result;
}
Also used : JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList)

Aggregations

LookupValuesList (de.metas.ui.web.window.datatypes.LookupValuesList)20 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)8 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)8 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)7 LookupDataSource (de.metas.ui.web.window.model.lookup.LookupDataSource)7 List (java.util.List)7 NonNull (lombok.NonNull)7 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)6 ImmutableList (com.google.common.collect.ImmutableList)5 LogManager (de.metas.logging.LogManager)4 ActionType (de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType)4 LookupDataSourceContext (de.metas.ui.web.window.model.lookup.LookupDataSourceContext)4 Set (java.util.Set)4 Services (org.adempiere.util.Services)4 DisplayType (org.compiere.util.DisplayType)4 I_M_HU (de.metas.handlingunits.model.I_M_HU)3 Check (de.metas.printing.esb.base.util.Check)3 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)3 StringLookupValue (de.metas.ui.web.window.datatypes.LookupValue.StringLookupValue)3 LookupDataSourceFactory (de.metas.ui.web.window.model.lookup.LookupDataSourceFactory)3