Skip to content

Commit

Permalink
Code cleanup, fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed May 11, 2020
1 parent 1f3e613 commit 0038b9a
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
/*
* #%L
* de.metas.adempiere.adempiere.base
* %%
* Copyright (C) 2020 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

package org.adempiere.warehouse.api;

import de.metas.location.CountryId;
import de.metas.organization.OrgId;
import de.metas.util.ISingletonService;
import org.adempiere.warehouse.LocatorId;
import org.adempiere.warehouse.WarehouseId;
import org.compiere.model.I_M_Locator;
import org.compiere.model.I_M_Warehouse;

import de.metas.location.CountryId;
import de.metas.organization.OrgId;
import de.metas.util.ISingletonService;
import javax.annotation.Nullable;

public interface IWarehouseBL extends ISingletonService
{
Expand All @@ -23,16 +46,17 @@ public interface IWarehouseBL extends ISingletonService

/**
* Get the first default locatorId.
*
* <p>
* In case there is no default locator, get the first non default locator.
*
* <p>
* In case none found, create a new one, with the coordinates (0,0,0)
*
* @param warehouse
* @return default locator's Id; never return null
*/
LocatorId getDefaultLocatorId(WarehouseId warehouse);

@Nullable
CountryId getCountryId(WarehouseId warehouseId);

OrgId getWarehouseOrgId(WarehouseId warehouseId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package org.adempiere.warehouse.api.impl;

import static org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx;

/*
* #%L
* de.metas.adempiere.adempiere.base
* %%
* Copyright (C) 2015 metas GmbH
* Copyright (C) 2020 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand All @@ -24,6 +20,10 @@
* #L%
*/

package org.adempiere.warehouse.api.impl;

import static org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx;

import java.util.List;

import org.adempiere.warehouse.LocatorId;
Expand All @@ -43,6 +43,8 @@
import de.metas.util.Services;
import lombok.NonNull;

import javax.annotation.Nullable;

public class WarehouseBL implements IWarehouseBL
{
private final transient Logger logger = LogManager.getLogger(getClass());
Expand Down Expand Up @@ -141,6 +143,7 @@ private I_C_Location getC_Location(final I_M_Warehouse warehouse)
return location;
}

@Nullable
@Override
public CountryId getCountryId(@NonNull final WarehouseId warehouseId)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
package de.metas.handlingunits.hutransaction;

import java.util.Date;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
/*
* #%L
* de.metas.handlingunits.base
* %%
* Copyright (C) 2020 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

import org.adempiere.model.PlainContextAware;
import org.adempiere.util.lang.IContextAware;
import org.adempiere.util.lang.Mutable;
import org.compiere.model.I_C_UOM;
import org.compiere.model.I_M_Product;
import org.compiere.model.I_M_Transaction;
package de.metas.handlingunits.hutransaction;

import de.metas.handlingunits.IHUContext;
import de.metas.handlingunits.allocation.IAllocationDestination;
Expand All @@ -28,9 +38,20 @@
import de.metas.util.ISingletonService;
import de.metas.util.Services;
import lombok.NonNull;
import org.adempiere.model.PlainContextAware;
import org.adempiere.util.lang.IContextAware;
import org.adempiere.util.lang.Mutable;
import org.compiere.model.I_C_UOM;
import org.compiere.model.I_M_Product;
import org.compiere.model.I_M_Transaction;

import javax.annotation.Nullable;
import java.util.Date;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

/**
*
* Service to create and "destroy" handling units (instances).
* HUs can be created be transferring material from a {@link org.compiere.model.I_M_Transaction}.<br>
* <br>
Expand All @@ -40,7 +61,6 @@
* <br>
* All methods in this class create one {@link de.metas.handlingunits.model.I_M_HU_Trx_Hdr} with at least two {@link de.metas.handlingunits.model.I_M_HU_Trx_Line}s. Each trx-line references either a
* {@link de.metas.handlingunits.model.I_M_HU_Item} or an {@link org.compiere.model.I_M_TransactionAllocation}.
*
*/
public interface IHUTrxBL extends ISingletonService
{
Expand All @@ -66,21 +86,24 @@ public interface IHUTrxBL extends ISingletonService

/**
* Register given {@link IHUTrxListener}.
*
* <p>
* If <code>trxListener</code> was already registered then it won't be registered again.
*
* @param trxListener
*/
void addListener(IHUTrxListener trxListener);

/** @return all system registered transaction listeners (wrapped by a composite) */
/**
* @return all system registered transaction listeners (wrapped by a composite)
*/
IHUTrxListener getHUTrxListeners();

/** @return all system registered transaction listeners */
/**
* @return all system registered transaction listeners
*/
List<IHUTrxListener> getHUTrxListenersList();

/**
*
* @param trxLine
* @param modelClass
* @return the record that is referenced by the given {@code trxLine} via its {@code AD_Table_ID} and {@code Record_ID} values, or <code>null</code>.
Expand All @@ -91,7 +114,7 @@ public interface IHUTrxBL extends ISingletonService

/**
* Create reversals of given transaction lines and process them.
*
* <p>
* All reversals will be grouped in one transaction header.
*
* <code>trxLines</code> shall contain the transaction but also the counterpart transaction. If not, an error will be thrown.
Expand All @@ -105,14 +128,14 @@ public interface IHUTrxBL extends ISingletonService
* Link a given {@code hu} to its parent.
* <p>
* <b>IMPORTANT:</b> Don't do transaction management (TODO: check if this can be added).
*
*
* @param huContext
* @param parentHUItem can be <code>null</code> to indicate that the HU shall be removed from its parent. If the given item has the same <code>M_HU_Item_ID</code> as the given <code>hu</code>'s
* <code>M_HU_Item_Parent_ID</code>, or if both this parameter and the hu's parent item are <code>null</code>, then the method does nothing.
* @param parentHUItem can be <code>null</code> to indicate that the HU shall be removed from its parent. If the given item has the same <code>M_HU_Item_ID</code> as the given <code>hu</code>'s
* <code>M_HU_Item_Parent_ID</code>, or if both this parameter and the hu's parent item are <code>null</code>, then the method does nothing.
* @param hu
* @param destroyOldParentIfEmptyStorage if true, it will check if old parent is empty after removing given HU from it and if yes, it will destroy it
*/
void setParentHU(IHUContext huContext, I_M_HU_Item parentHUItem, I_M_HU hu, boolean destroyOldParentIfEmptyStorage);
void setParentHU(IHUContext huContext, @Nullable I_M_HU_Item parentHUItem, I_M_HU hu, boolean destroyOldParentIfEmptyStorage);

/**
* Same as calling {@link #setParentHU(IHUContext, I_M_HU_Item, I_M_HU, boolean)} with <code>destroyOldParentIfEmptyStorage</code>=<code>false</code>.
Expand All @@ -121,7 +144,7 @@ public interface IHUTrxBL extends ISingletonService
* @param parentHUItem
* @param hu
*/
void setParentHU(IHUContext huContext, I_M_HU_Item parentHUItem, I_M_HU hu);
void setParentHU(IHUContext huContext, @Nullable I_M_HU_Item parentHUItem, I_M_HU hu);

/**
* Take out the given HU from it's parent (if it's not already a top level HU)
Expand All @@ -134,15 +157,17 @@ public interface IHUTrxBL extends ISingletonService

IHUContextProcessorExecutor createHUContextProcessorExecutor(IContextAware context);

/** @return executor which will run using current environment and thread inherited trx */
/**
* @return executor which will run using current environment and thread inherited trx
*/
default IHUContextProcessorExecutor createHUContextProcessorExecutor()
{
return createHUContextProcessorExecutor(PlainContextAware.newWithThreadInheritedTrx());
}

/**
* Convenient method to process using current env and thread inherited trx.
*
*
* @param processor
*/
default void process(final Consumer<IHUContext> processor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package de.metas.handlingunits.hutransaction.impl;

import java.util.ArrayList;

/*
* #%L
* de.metas.handlingunits.base
* %%
* Copyright (C) 2015 metas GmbH
* Copyright (C) 2020 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
Expand All @@ -24,6 +20,10 @@
* #L%
*/

package de.metas.handlingunits.hutransaction.impl;

import java.util.ArrayList;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -68,6 +68,8 @@
import de.metas.util.Services;
import lombok.NonNull;

import javax.annotation.Nullable;

public class HUTrxBL implements IHUTrxBL
{
private final CompositeHUTrxListener _trxListeners = new CompositeHUTrxListener();
Expand Down Expand Up @@ -190,15 +192,15 @@ public void reverseTrxLines(final IHUContext huContext, final List<I_M_HU_Trx_Li
}

@Override
public void setParentHU(final IHUContext huContext, final I_M_HU_Item parentHUItem, final I_M_HU hu)
public void setParentHU(final IHUContext huContext, final @Nullable I_M_HU_Item parentHUItem, final I_M_HU hu)
{
final boolean destroyOldParentIfEmptyStorage = true;
setParentHU(huContext, parentHUItem, hu, destroyOldParentIfEmptyStorage);
}

@Override
public void setParentHU(final IHUContext huContext,
final I_M_HU_Item parentHUItem,
@Nullable final I_M_HU_Item parentHUItem,
@NonNull final I_M_HU hu,
final boolean destroyOldParentIfEmptyStorage)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
package de.metas.handlingunits.movement.api;
/*
* #%L
* de.metas.handlingunits.base
* %%
* Copyright (C) 2020 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

import java.util.List;
import java.util.Properties;

import org.compiere.model.I_M_Locator;
import org.compiere.model.I_M_Warehouse;
package de.metas.handlingunits.movement.api;

import de.metas.handlingunits.IHUAssignmentBL;
import de.metas.handlingunits.model.I_M_HU;
import de.metas.handlingunits.model.I_M_MovementLine;
import de.metas.interfaces.I_M_Movement;
import de.metas.util.ISingletonService;
import org.compiere.model.I_M_Locator;
import org.compiere.model.I_M_Warehouse;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Properties;

public interface IHUMovementBL extends ISingletonService
{
Expand All @@ -27,7 +49,7 @@ public interface IHUMovementBL extends ISingletonService

/**
* NOTE: Only use for packing material Movement Lines!!!! Note 2: the movement line is saved
*
* <p>
* Set the correct activity in the movement line In the case of packing material movement lines, this is always the activity of the prosuct ( Usually Gebinde)
*
* @param movementLine
Expand All @@ -45,17 +67,17 @@ public interface IHUMovementBL extends ISingletonService
/**
* Method uses <code>AD_SysConfig</code> {@value #SYSCONFIG_DirectMove_Warehouse_ID} to get the {@link I_M_Warehouse} for direct movements.
*
* @param ctx the context we use to get the <code>AD_Client_ID</code> and <code>AD_Org_ID</code> used to retrieve the AD_SysConfig value.
* @param ctx the context we use to get the <code>AD_Client_ID</code> and <code>AD_Org_ID</code> used to retrieve the AD_SysConfig value.
* @param throwEx if <code>true</code> then the method throws a exception rather than of returning <code>null</code>.
*
* @task http://dewiki908/mediawiki/index.php/08205_HU_Pos_Inventory_move_Button_%28105838505937%29
* @return {@link I_M_Warehouse} for direct movements or <code>null</code>.
* @task http://dewiki908/mediawiki/index.php/08205_HU_Pos_Inventory_move_Button_%28105838505937%29
*/
@Nullable
I_M_Warehouse getDirectMove_Warehouse(Properties ctx, boolean throwEx);

/**
* Assigns given HU to given movement line
*
*
* @param movementLine
* @param hu
* @param isTransferPackingMaterials
Expand Down

0 comments on commit 0038b9a

Please sign in to comment.