use of org.adempiere.model.IContextAware in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method assignSerialNumberToCU.
private void assignSerialNumberToCU(final int huId, final String serialNo) {
final I_M_HU hu = create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_ThreadInherited);
final IContextAware ctxAware = getContextAware(hu);
final IHUContext huContext = handlingUnitsBL.createMutableHUContext(ctxAware);
final IAttributeStorage attributeStorage = getAttributeStorage(huContext, hu);
final I_M_Attribute serialNoAttribute = serialNoDAO.getSerialNoAttribute(ctxAware.getCtx());
Check.errorUnless(attributeStorage.hasAttribute(serialNoAttribute), "There is no SerialNo attribute {} defined for the handling unit {}", serialNoAttribute, hu);
attributeStorage.setValue(serialNoAttribute, serialNo.trim());
attributeStorage.saveChangesIfNeeded();
}
use of org.adempiere.model.IContextAware in project metasfresh-webui-api by metasfresh.
the class UserNotificationDetailMessageFormat method formatTableRecordReference.
@Override
protected String formatTableRecordReference(final ITableRecordReference recordRef) {
// Retrieve the record
Object record;
try {
final IContextAware context = PlainContextAware.createUsingOutOfTransaction();
record = recordRef.getModel(context);
} catch (final Exception e) {
logger.info("Failed retrieving record for " + recordRef, e);
return "<" + recordRef.getRecord_ID() + ">";
}
final String documentNo = Services.get(IDocumentBL.class).getDocumentNo(record);
return documentNo;
}
Aggregations