Search in sources :

Example 1 with IAttributeStorage

use of de.metas.handlingunits.attribute.storage.IAttributeStorage in project metasfresh-webui-api by metasfresh.

the class WEBUIHUCreationWithSerialNumberService method getAttributeStorage.

private final IAttributeStorage getAttributeStorage(final IHUContext huContext, final I_M_HU hu) {
    final IAttributeStorageFactory attributeStorageFactory = huContext.getHUAttributeStorageFactory();
    final IAttributeStorage attributeStorage = attributeStorageFactory.getAttributeStorage(hu);
    return attributeStorage;
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) IAttributeStorageFactory(de.metas.handlingunits.attribute.storage.IAttributeStorageFactory)

Example 2 with IAttributeStorage

use of de.metas.handlingunits.attribute.storage.IAttributeStorage in project metasfresh-webui-api by metasfresh.

the class HUEditorRowAttributesProvider method createRowAttributes.

private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
    final int huId = key.getHuId().toInt();
    final I_M_HU hu = InterfaceWrapperHelper.create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_None);
    if (hu == null) {
        throw new IllegalArgumentException("No HU found for M_HU_ID=" + huId);
    }
    final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
    attributesStorage.setSaveOnChange(true);
    final DocumentId documentTypeId = DocumentId.of(huId);
    final DocumentId huEditorRowId = key.getHuEditorRowId();
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);
    final boolean rowAttributesReadonly = // readonly if the provider shall provide readonly attributes
    isReadonly() || // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
    !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus());
    return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) I_M_HU(de.metas.handlingunits.model.I_M_HU) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 3 with IAttributeStorage

use of de.metas.handlingunits.attribute.storage.IAttributeStorage 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)

Aggregations

IAttributeStorage (de.metas.handlingunits.attribute.storage.IAttributeStorage)3 I_M_HU (de.metas.handlingunits.model.I_M_HU)2 IHUContext (de.metas.handlingunits.IHUContext)1 IAttributeStorageFactory (de.metas.handlingunits.attribute.storage.IAttributeStorageFactory)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)1 IContextAware (org.adempiere.model.IContextAware)1 I_M_Attribute (org.compiere.model.I_M_Attribute)1