Search in sources :

Example 1 with IContextAware

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();
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_Attribute(org.compiere.model.I_M_Attribute) IContextAware(org.adempiere.model.IContextAware) IHUContext(de.metas.handlingunits.IHUContext)

Example 2 with IContextAware

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;
}
Also used : IDocumentBL(de.metas.document.engine.IDocumentBL) IContextAware(org.adempiere.model.IContextAware)

Aggregations

IContextAware (org.adempiere.model.IContextAware)2 IDocumentBL (de.metas.document.engine.IDocumentBL)1 IHUContext (de.metas.handlingunits.IHUContext)1 IAttributeStorage (de.metas.handlingunits.attribute.storage.IAttributeStorage)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_Attribute (org.compiere.model.I_M_Attribute)1