Skip to content

Commit

Permalink
refactor shipment schedule invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Nov 20, 2019
1 parent 5c95b72 commit 74b3af9
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 325 deletions.
@@ -1,7 +1,5 @@
package de.metas.handlingunits.model.validator;

import lombok.NonNull;

import java.util.List;

import org.adempiere.ad.modelvalidator.annotations.Interceptor;
Expand All @@ -18,10 +16,11 @@
import de.metas.handlingunits.IHandlingUnitsDAO;
import de.metas.handlingunits.exceptions.HUException;
import de.metas.handlingunits.model.I_M_HU;
import de.metas.inoutcandidate.api.IShipmentScheduleInvalidateBL;
import de.metas.logging.LogManager;
import de.metas.storage.IStorageListeners;
import de.metas.storage.spi.hu.impl.StorageSegmentFromHU;
import de.metas.util.Services;
import lombok.NonNull;

@Interceptor(I_M_HU.class)
public class M_HU
Expand Down Expand Up @@ -159,6 +158,6 @@ public void fireStorageSegmentChanged(final I_M_HU hu)
}

final StorageSegmentFromHU storageSegment = new StorageSegmentFromHU(hu);
Services.get(IStorageListeners.class).notifyStorageSegmentChanged(storageSegment);
Services.get(IShipmentScheduleInvalidateBL.class).notifySegmentChanged(storageSegment);
}
}
Expand Up @@ -29,7 +29,7 @@

import de.metas.handlingunits.model.I_M_HU;
import de.metas.handlingunits.model.I_M_HU_Attribute;
import de.metas.storage.IStorageListeners;
import de.metas.inoutcandidate.api.IShipmentScheduleInvalidateBL;
import de.metas.storage.IStorageSegment;
import de.metas.storage.spi.hu.impl.StorageSegmentFromHUAttribute;
import de.metas.util.Services;
Expand All @@ -55,7 +55,7 @@ public void fireAttributeSegmentChanged(final I_M_HU_Attribute huAttribute)
{
// NOTE: Fire just notifying about the segment change and later on it will be determined if this attribute change really affects the storage.
final IStorageSegment storageSegment = new StorageSegmentFromHUAttribute(huAttribute);
Services.get(IStorageListeners.class).notifyStorageSegmentChanged(storageSegment);
Services.get(IShipmentScheduleInvalidateBL.class).notifySegmentChanged(storageSegment);
}

}
Expand Up @@ -27,7 +27,7 @@
import org.compiere.model.ModelValidator;

import de.metas.handlingunits.model.I_M_HU_Storage;
import de.metas.storage.IStorageListeners;
import de.metas.inoutcandidate.api.IShipmentScheduleInvalidateBL;
import de.metas.storage.IStorageSegment;
import de.metas.storage.spi.hu.impl.StorageSegmentFromHUStorage;
import de.metas.util.Services;
Expand All @@ -39,7 +39,7 @@ public class M_HU_Storage

private M_HU_Storage()
{
};
}

@ModelChange(timings = { ModelValidator.TYPE_AFTER_NEW, ModelValidator.TYPE_AFTER_CHANGE, ModelValidator.TYPE_AFTER_DELETE }, ifColumnsChanged = {
I_M_HU_Storage.COLUMNNAME_IsActive,
Expand All @@ -51,9 +51,8 @@ public void fireStorageSegmentChanged(final I_M_HU_Storage huStorage)
{
// TODO: notify segment changed only after transaction is commited.
// And in this case, it would be nice if we could aggregate the notifications and fire them all together at once.
final IStorageListeners storageListeners = Services.get(IStorageListeners.class);

final IStorageSegment storageSegment = new StorageSegmentFromHUStorage(huStorage);
storageListeners.notifyStorageSegmentChanged(storageSegment);
Services.get(IShipmentScheduleInvalidateBL.class).notifySegmentChanged(storageSegment);
}
}
Expand Up @@ -131,7 +131,7 @@ public void onMovementQtyChange(final I_M_InOutLine inOutLine)

final IShipmentScheduleInvalidateBL shipmentScheduleInvalidateBL = Services.get(IShipmentScheduleInvalidateBL.class);
shipmentScheduleInvalidateBL.invalidateJustForLine(inOutLine); // task 08749: the segment invalidation might not invalidate the sched(s) for this line
shipmentScheduleInvalidateBL.invalidateSegmentForLine(inOutLine);
shipmentScheduleInvalidateBL.notifySegmentChangedForShipmentLine(inOutLine);
}

private void createOrUpdateShipmentScheduleQtyPicked(
Expand Down
Expand Up @@ -180,6 +180,6 @@ public void invalidate(final I_M_ShipmentSchedule shipmentSchedule)

final IShipmentScheduleInvalidateBL invalidSchedulesService = Services.get(IShipmentScheduleInvalidateBL.class);
invalidSchedulesService.invalidateShipmentSchedule(shipmentScheduleId); // 08746: make sure that at any rate, the schedule itself is invalidated, even if it has delivery rule "force"
invalidSchedulesService.invalidateSegmentForShipmentSchedule(shipmentSchedule);
invalidSchedulesService.notifySegmentChangedForShipmentSchedule(shipmentSchedule);
}
}

This file was deleted.

This file was deleted.

Expand Up @@ -35,8 +35,6 @@

/**
* Used to retrieve {@link IStorageRecord}s. Use {@link IStorageEngine#newStorageQuery()} to get an instance.
* <p>
* Also see {@link IStorageSegment}.
*/
public interface IStorageQuery
{
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -48,9 +48,9 @@ public interface IShipmentScheduleInvalidateBL extends ISingletonService
void invalidateJustForLine(I_M_InOutLine shipmentLine);

/**
* See {@link #invalidateSegmentForLine(I_M_InOutLine)}.
* See {@link #notifySegmentChangedForShipmentLine(I_M_InOutLine)}.
*/
void invalidateSegmentsForLines(I_M_InOut shipment);
void notifySegmentsChangedForShipment(I_M_InOut shipment);

/**
* Invalidates all shipment schedules that have the same product, bPartner, ASI and locator as the given line<br>
Expand All @@ -65,18 +65,18 @@ public interface IShipmentScheduleInvalidateBL extends ISingletonService
* @param shipmentLine
* @see IShipmentSchedulePA#invalidateStorageSegments(java.util.Collection)
*/
void invalidateSegmentForLine(I_M_InOutLine shipmentLine);
void notifySegmentChangedForShipmentLine(I_M_InOutLine shipmentLine);

/**
* For the given <code>schedule</code>, invalidate all shipment schedules that have the same product and warehouse and a matching ASI.
*/
void invalidateSegmentForShipmentSchedule(I_M_ShipmentSchedule schedule);
void notifySegmentChangedForShipmentSchedule(I_M_ShipmentSchedule schedule);

/**
* For the given <code>orderLine</code>, invalidate all shipment schedules that have the same product and warehouse and a matching ASI.
* and <b>that that do not have "force" as delivery rule</b>.<br>
*/
void invalidateSegmentForOrderLine(I_C_OrderLine orderLine);
void notifySegmentChangedForOrderLine(I_C_OrderLine orderLine);

/**
* Invalidate the shipment schedule referencing the given <code>orderLine</code>.
Expand All @@ -100,5 +100,13 @@ public interface IShipmentScheduleInvalidateBL extends ISingletonService
* @param headerAggregationKeys
*/
void invalidateForHeaderAggregationKeys(Set<String> headerAggregationKeys);

void notifySegmentChanged(IStorageSegment storageSegment);

/**
* Notify the registered listeners that a a bunch of segments changed. Maybe they can gain a performance benefit from processing them all at once.
*
* @param storageSegments
*/
void notifySegmentsChanged(Collection<IStorageSegment> storageSegments);
}

0 comments on commit 74b3af9

Please sign in to comment.