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