Skip to content

Commit

Permalink
Update references to TableRecordReference; fix warnings (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Apr 22, 2020
1 parent 09f7936 commit 070e8c6
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 104 deletions.
@@ -1,28 +1,29 @@
package de.metas.dlm.partitioner.impl;

import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import org.adempiere.ad.dao.IQueryBL;
import org.adempiere.ad.dao.IQueryBuilder;
import org.adempiere.ad.table.api.IADTableDAO;
import org.adempiere.ad.trx.api.ITrxManager;
import org.adempiere.model.InterfaceWrapperHelper;
import org.adempiere.model.PlainContextAware;
import org.adempiere.util.lang.IContextAware;
import org.adempiere.util.lang.ITableRecordReference;
import org.adempiere.util.lang.Mutable;
import org.adempiere.util.lang.impl.TableRecordReference;
import org.compiere.util.TrxRunnable;
import org.slf4j.Logger;
/*
* #%L
* metasfresh-dlm-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 com.google.common.annotations.VisibleForTesting;
package de.metas.dlm.partitioner.impl;

import ch.qos.logback.classic.Level;
import com.google.common.annotations.VisibleForTesting;
import de.metas.adempiere.service.IColumnBL;
import de.metas.dlm.IDLMService;
import de.metas.dlm.Partition;
Expand All @@ -40,28 +41,25 @@
import de.metas.util.Check;
import de.metas.util.Loggables;
import de.metas.util.Services;
import org.adempiere.ad.dao.IQueryBL;
import org.adempiere.ad.dao.IQueryBuilder;
import org.adempiere.ad.table.api.IADTableDAO;
import org.adempiere.ad.trx.api.ITrxManager;
import org.adempiere.model.InterfaceWrapperHelper;
import org.adempiere.model.PlainContextAware;
import org.adempiere.util.lang.IContextAware;
import org.adempiere.util.lang.ITableRecordReference;
import org.adempiere.util.lang.Mutable;
import org.adempiere.util.lang.impl.TableRecordReference;
import org.compiere.util.TrxRunnable;
import org.slf4j.Logger;

/*
* #%L
* metasfresh-dlm
* %%
* Copyright (C) 2016 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.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

public class RecordCrawlerService implements IRecordCrawlerService
{
Expand All @@ -82,7 +80,8 @@ public IIterateResult crawl(
// otherwise, the partiton we are in truth working on just now would be flagged as "completed" in the DB until further notice
storeIterateResult(config, result, ctxAware);

mainLoop: while (!result.isQueueEmpty())
mainLoop:
while (!result.isQueueEmpty())
{
final ITableRecordReference currentReference = result.nextFromQueue();
final IDLMAware currentRecord = currentReference.getModel(ctxAware, IDLMAware.class);
Expand Down Expand Up @@ -153,7 +152,7 @@ public IIterateResult crawl(
continue;
}

final TableRecordReference forwardReference = new TableRecordReference(forwardTableName, forwardKey);
final TableRecordReference forwardReference = TableRecordReference.of(forwardTableName, forwardKey);

final boolean recordWasAlreadyAddedBefore = result.contains(forwardReference);
if (recordWasAlreadyAddedBefore)
Expand Down Expand Up @@ -183,10 +182,10 @@ public IIterateResult crawl(
logger.debug("{}[{}] forward: referenced IDLMAware={} already has DLM_Partition_ID={}",
currentTableName, currentRecordId, forwardRecord, forwardRecord.getDLM_Partition_ID());
}
if(AddResult.STOP.equals(addResult))
if (AddResult.STOP.equals(addResult))
{
Loggables.withLogger(logger, Level.WARN)
.addLog("The crawler was signaled to stop when it added ReferencedRecord={} to the result. Stopping now", forwardReference);
.addLog("The crawler was signaled to stop when it added ReferencedRecord={} to the result. Stopping now", forwardReference);
break mainLoop;
}
}
Expand Down Expand Up @@ -318,8 +317,8 @@ private void storeIterateResult(final PartitionConfig config,
* <p>
* This method is invoked in its own transaction via {@link ITrxManager#runInNewTrx(TrxRunnable)}.
*
* @param config not actually used in this method, but forwarded to the new {@link Partition} that <code>clearAfterPartitionStored</code> will be called with.
* @param result side-effect: the method will call {@link IterateResult#clearAfterPartitionStored(Partition))}, so the stored partition will be contained within the result
* @param config not actually used in this method, but forwarded to the new {@link Partition} that <code>clearAfterPartitionStored</code> will be called with.
* @param result side-effect: the method will call {@link IterateResult#clearAfterPartitionStored(Partition))}, so the stored partition will be contained within the result
* @param ctxAware
* @return
*/
Expand Down
@@ -1,10 +1,8 @@
package de.metas.bpartner.service.async.spi.impl;

/*
* #%L
* de.metas.swat.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 @@ -22,6 +20,8 @@
* #L%
*/

package de.metas.bpartner.service.async.spi.impl;

import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -91,7 +91,7 @@ protected String extractTrxNameFromItem(final BPartnerToUpdate item)
@Override
protected Object extractModelToEnqueueFromItem(final Collector collector, final BPartnerToUpdate item)
{
return new TableRecordReference(I_C_BPartner.Table_Name, item.getBpartnerId());
return TableRecordReference.of(I_C_BPartner.Table_Name, item.getBpartnerId());
}

@Override
Expand Down
@@ -1,3 +1,25 @@
/*
* #%L
* de.metas.swat.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 de.metas.request.service.async.spi.impl;

import static org.adempiere.model.InterfaceWrapperHelper.load;
Expand All @@ -18,28 +40,6 @@
import de.metas.util.Check;
import de.metas.util.Services;

/*
* #%L
* de.metas.swat.base
* %%
* Copyright (C) 2018 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%
*/

public class C_Request_CreateFromDDOrder_Async extends WorkpackageProcessorAdapter
{

Expand Down Expand Up @@ -108,7 +108,7 @@ protected String extractTrxNameFromItem(final I_DD_OrderLine item)
@Override
protected Object extractModelToEnqueueFromItem(final Collector collector, final I_DD_OrderLine item)
{
return new TableRecordReference(I_DD_OrderLine.Table_Name, item.getDD_OrderLine_ID());
return TableRecordReference.of(I_DD_OrderLine.Table_Name, item.getDD_OrderLine_ID());
}
};

Expand Down
@@ -1,50 +1,47 @@
package de.metas.request.service.async.spi.impl;

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

import org.adempiere.ad.trx.api.ITrx;
import org.adempiere.util.lang.impl.TableRecordReference;
import org.compiere.util.Env;

import com.google.common.base.MoreObjects;

import de.metas.async.api.IQueueDAO;
import de.metas.async.model.I_C_Queue_WorkPackage;
import de.metas.async.spi.WorkpackageProcessorAdapter;
import de.metas.async.spi.WorkpackagesOnCommitSchedulerTemplate;
import de.metas.inout.model.I_M_InOutLine;
import de.metas.request.api.IRequestBL;
import de.metas.util.Services;

/*
* #%L
* de.metas.swat.base
* %%
* Copyright (C) 2016 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
* 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 de.metas.request.service.async.spi.impl;

import com.google.common.base.MoreObjects;
import de.metas.async.api.IQueueDAO;
import de.metas.async.model.I_C_Queue_WorkPackage;
import de.metas.async.spi.WorkpackageProcessorAdapter;
import de.metas.async.spi.WorkpackagesOnCommitSchedulerTemplate;
import de.metas.inout.model.I_M_InOutLine;
import de.metas.request.api.IRequestBL;
import de.metas.util.Services;
import org.adempiere.ad.trx.api.ITrx;
import org.adempiere.util.lang.impl.TableRecordReference;
import org.compiere.util.Env;

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

public class C_Request_CreateFromInout_Async extends WorkpackageProcessorAdapter
{
/**
*
* Schedule the request creation based on the given inoutline ids
*
* <p>
* These requests will contain information taken from the lines and from their inout headers:
* <li>inout
* <li>product
Expand Down Expand Up @@ -78,9 +75,8 @@ public static void createWorkpackage(final List<Integer> inOutLineIds)
/**
* Class to keep information about the inout lines with quality issues (Quality Discount Percent).
* This model will be used ion the
*
* @author metas-dev <dev@metasfresh.com>
*
* @author metas-dev <dev@metasfresh.com>
*/
private static final class InOutLineWithQualityIssues
{
Expand Down Expand Up @@ -117,7 +113,9 @@ public int getM_InOutLine_ID()
protected boolean isEligibleForScheduling(final InOutLineWithQualityIssues model)
{
return model != null && model.getM_InOutLine_ID() > 0;
};
}

;

@Override
protected Properties extractCtxFromItem(final InOutLineWithQualityIssues item)
Expand All @@ -134,7 +132,7 @@ protected String extractTrxNameFromItem(final InOutLineWithQualityIssues item)
@Override
protected Object extractModelToEnqueueFromItem(final Collector collector, final InOutLineWithQualityIssues item)
{
return new TableRecordReference(I_M_InOutLine.Table_Name, item.getM_InOutLine_ID());
return TableRecordReference.of(I_M_InOutLine.Table_Name, item.getM_InOutLine_ID());
}
};

Expand Down

0 comments on commit 070e8c6

Please sign in to comment.