Skip to content

Commit

Permalink
gh5440 - Easy shipment candidate recording (#5452)
Browse files Browse the repository at this point in the history
gh5440 - Easy shipment candidate recording
  • Loading branch information
metas-ts committed Aug 27, 2019
2 parents 6b99cfd + 91bf37b commit c009f4c
Show file tree
Hide file tree
Showing 18 changed files with 1,896 additions and 140 deletions.
Expand Up @@ -23,11 +23,11 @@
*
* 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
* 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
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Expand Down Expand Up @@ -77,7 +77,6 @@ public static final LogicExpressionResult namedConstant(final String name, final

private LogicExpressionResult(final String name, final Boolean value, final ILogicExpression expression, final Map<CtxName, String> usedParameters)
{
super();
this.name = name;
this.value = value == null ? false : value;
this.expression = expression;
Expand All @@ -87,16 +86,17 @@ private LogicExpressionResult(final String name, final Boolean value, final ILog
@Override
public String toString()
{
if (_toString == null)
String toString = _toString;
if (toString == null)
{
_toString = MoreObjects.toStringHelper(value ? "TRUE" : "FALSE")
toString = _toString = MoreObjects.toStringHelper(value ? "TRUE" : "FALSE")
.omitNullValues()
.add("name", name)
.add("expression", expression)
.add("usedParameters", usedParameters)
.toString();
}
return _toString;
return toString;
}

@Override
Expand Down Expand Up @@ -165,7 +165,7 @@ public boolean booleanValue()
{
return value;
}

public boolean isTrue()
{
return value;
Expand All @@ -175,7 +175,7 @@ public boolean isFalse()
{
return !value;
}

public String getName()
{
return name;
Expand Down
Expand Up @@ -136,7 +136,7 @@ public class VPAttributeDialog extends CDialog implements ActionListener
private final int m_WindowNo;
private final IVPAttributeContext attributeContext;
private final MAttributeSet _attributeSet;
private final MAttributeSetInstance _asiTemplate;
private final I_M_AttributeSetInstance _asiTemplate;
private final List<I_M_Attribute> _availableAttributes;
private final boolean _allowSelectExistingASI;

Expand Down Expand Up @@ -250,14 +250,14 @@ private boolean isASITemplateNew()
return asiTemplate == null || asiTemplate.getM_AttributeSetInstance_ID() <= 0;
}

private MAttributeSetInstance getASITemplate()
private I_M_AttributeSetInstance getASITemplate()
{
return _asiTemplate;
}

private MAttributeInstance getAITemplate(final I_M_Attribute attribute)
{
final MAttributeSetInstance asiTemplate = getASITemplate();
final I_M_AttributeSetInstance asiTemplate = getASITemplate();
if (asiTemplate == null)
{
return null;
Expand Down Expand Up @@ -919,7 +919,7 @@ private I_M_AttributeSetInstance saveSelection0()
log.info("");

final MAttributeSet attributeSet = getM_AttributeSet();
final MAttributeSetInstance asiTemplate2 = getASITemplate();
final I_M_AttributeSetInstance asiTemplate2 = getASITemplate();

// Create a new ASI which is copying the existing one

Expand Down
@@ -0,0 +1,85 @@
-- 2019-08-24T07:47:15.176Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:47:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14097
;

-- 2019-08-24T07:50:21.508Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:50:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=65576
;

-- 2019-08-24T07:51:00.545Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:51:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=55321
;

-- 2019-08-24T07:51:20.021Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:51:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14100
;

-- 2019-08-24T07:51:36.240Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:51:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2223
;

-- 2019-08-24T07:51:40.104Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:51:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=14099
;

-- 2019-08-24T07:51:48.576Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:51:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=54299
;

-- 2019-08-24T07:51:52.012Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:51:52','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=54307
;

-- 2019-08-24T07:52:35.879Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=546475
;

-- 2019-08-24T07:52:39.126Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=546476
;

-- 2019-08-24T07:52:41.933Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=546478
;

-- 2019-08-24T07:52:45.002Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=546481
;

-- 2019-08-24T07:52:47.500Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=548495
;

-- 2019-08-24T07:52:50.192Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=548497
;

-- 2019-08-24T07:52:54.477Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Column SET AD_Reference_Value_ID=540420,Updated=TO_TIMESTAMP('2019-08-24 10:52:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=568054
;

-- 2019-08-24T07:53:32.235Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Reference_Trl WHERE AD_Reference_ID=197
;

-- 2019-08-24T07:53:32.257Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Reference WHERE AD_Reference_ID=197
;

Expand Up @@ -96,12 +96,9 @@ default AttributeSetId getAttributeSetId(final int productId)
}

/**
* If the product has an Attribute Set take it from there; If not, take it from the product category of the product
*
* @param product
* @return
* @return product/product category's attribute set or null
*/
I_M_AttributeSet getM_AttributeSet(I_M_Product product);
I_M_AttributeSet getAttributeSetOrNull(ProductId productId);

I_M_AttributeSetInstance getCreateASI(Properties ctx, int M_AttributeSetInstance_ID, int M_Product_ID);

Expand Down
Expand Up @@ -248,24 +248,15 @@ public AttributeSetId getAttributeSetId(@NonNull final ProductId productId)
return getAttributeSetId(product);
}

public I_M_AttributeSet getM_AttributeSet(@NonNull final ProductId productId)
@Override
public I_M_AttributeSet getAttributeSetOrNull(@NonNull final ProductId productId)
{
final AttributeSetId attributeSetId = getAttributeSetId(productId);
if (attributeSetId.isNone())
{
return null;
}
return Services.get(IAttributeDAO.class).getAttributeSetById(attributeSetId);
}

@Override
public I_M_AttributeSet getM_AttributeSet(I_M_Product product)
{
final AttributeSetId attributeSetId = getAttributeSetId(product);
if (attributeSetId.isNone())
{
return null;
}
return Services.get(IAttributeDAO.class).getAttributeSetById(attributeSetId);
}

Expand Down Expand Up @@ -362,7 +353,7 @@ public boolean isASIMandatory(@NonNull final ProductId productId, final boolean
@Override
public boolean isInstanceAttribute(@NonNull final ProductId productId)
{
final I_M_AttributeSet mas = getM_AttributeSet(productId);
final I_M_AttributeSet mas = getAttributeSetOrNull(productId);
return mas != null && mas.isInstanceAttribute();
}

Expand Down
@@ -1,5 +1,7 @@
package org.adempiere.mm.attributes.api;

import java.util.Collection;

/*
* #%L
* de.metas.adempiere.adempiere.base
Expand Down Expand Up @@ -49,19 +51,22 @@ public interface IAttributeDAO extends ISingletonService

I_M_Attribute getAttributeById(int attributeId);

I_M_Attribute getAttributeById(AttributeId attributeId);

<T extends I_M_Attribute> T getAttributeById(AttributeId attributeId, Class<T> type);

default I_M_Attribute getAttributeById(AttributeId attributeId)
{
return getAttributeById(attributeId, I_M_Attribute.class);
}
List<I_M_Attribute> getAttributesByIds(Collection<AttributeId> attributeIds);

/** @return attributeIds ordered by M_AttributeUse.SeqNo */
List<AttributeId> getAttributeIdsByAttributeSetId(AttributeSetId attributeSetId);

Set<AttributeId> getAttributeIdsByAttributeSetInstanceId(AttributeSetInstanceId attributeSetInstanceId);

/** @return attributes, ordered by M_AttributeUse.SeqNo */
List<I_M_Attribute> getAttributesByAttributeSetId(AttributeSetId attributeSetId);

List<I_M_Attribute> getAllAttributes();

String getAttributeCodeById(AttributeId attributeId);

/**
Expand Down Expand Up @@ -196,5 +201,4 @@ default ASICopy prepareCopy(final I_M_AttributeSetInstance fromASI)
boolean areAttributeSetsEqual(AttributeSetInstanceId firstASIId, AttributeSetInstanceId secondASIId);

I_M_AttributeSetInstance getAttributeSetInstanceById(AttributeSetInstanceId attributeSetInstanceId);

}
Expand Up @@ -98,13 +98,20 @@ public I_M_Attribute getAttributeById(final int attributeId)
return InterfaceWrapperHelper.loadOutOfTrx(attributeId, I_M_Attribute.class);
}

@Override
public I_M_Attribute getAttributeById(@NonNull final AttributeId attributeId)
{
return getAttributeById(attributeId, I_M_Attribute.class);
}

@Override
public <T extends I_M_Attribute> T getAttributeById(@NonNull final AttributeId attributeId, @NonNull Class<T> type)
{
// assume table level caching is enabled
return InterfaceWrapperHelper.loadOutOfTrx(attributeId, type);
}

@Override
public List<I_M_Attribute> getAttributesByIds(final Collection<AttributeId> attributeIds)
{
if (attributeIds.isEmpty())
Expand Down Expand Up @@ -137,6 +144,17 @@ public List<I_M_Attribute> getAttributesByAttributeSetId(@NonNull final Attribut
.collect(ImmutableList.toImmutableList());
}

@Override
public Set<AttributeId> getAttributeIdsByAttributeSetInstanceId(@NonNull final AttributeSetInstanceId attributeSetInstanceId)
{
return Services.get(IQueryBL.class)
.createQueryBuilderOutOfTrx(I_M_AttributeInstance.class)
.addEqualsFilter(I_M_AttributeInstance.COLUMN_M_AttributeSetInstance_ID, attributeSetInstanceId)
.andCollect(I_M_AttributeInstance.COLUMN_M_Attribute_ID)
.create()
.listIds(AttributeId::ofRepoId);
}

@Override
public String getAttributeCodeById(final AttributeId attributeId)
{
Expand Down Expand Up @@ -190,10 +208,23 @@ public AttributeId retrieveAttributeIdByValueOrNull(final String value)
return AttributeId.ofRepoIdOrNull(attributeId);
}

@Override
public List<I_M_Attribute> getAllAttributes()
{
return Services.get(IQueryBL.class)
.createQueryBuilderOutOfTrx(I_M_Attribute.class)
.addOnlyActiveRecordsFilter()
// .addOnlyContextClient()
.orderBy(I_M_Attribute.COLUMNNAME_Name)
.orderBy(I_M_Attribute.COLUMNNAME_M_Attribute_ID)
.create()
.list();
}

@Override
public List<I_M_AttributeValue> retrieveAttributeValues(final I_M_Attribute attribute)
{
final Map<String, I_M_AttributeValue> map = retrieveAttributeValuesMap(attribute, false/*includeInactive*/);
final Map<String, I_M_AttributeValue> map = retrieveAttributeValuesMap(attribute, false/* includeInactive */);
return ImmutableList.copyOf(map.values());
}

Expand Down Expand Up @@ -244,7 +275,7 @@ public I_M_AttributeValue retrieveAttributeValueOrNull(
}
else
{
return retrieveAttributeValuesMap(attribute, false/*includeInactive*/)
return retrieveAttributeValuesMap(attribute, false/* includeInactive */)
.values()
.stream()
.filter(av -> av.getM_AttributeValue_ID() == attributeValueId.getRepoId())
Expand Down Expand Up @@ -366,7 +397,7 @@ public I_M_AttributeInstance retrieveAttributeInstance(
@Override
public List<I_M_AttributeValue> retrieveFilteredAttributeValues(final I_M_Attribute attribute, final SOTrx soTrx)
{
return retrieveAttributeValuesMap(attribute, false/*includeInactive*/)
return retrieveAttributeValuesMap(attribute, false/* includeInactive */)
.values()
.stream()
.filter(av -> isAttributeValueMatchingSOTrx(av, soTrx))
Expand Down

0 comments on commit c009f4c

Please sign in to comment.