Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
metas-ts committed Apr 16, 2020
1 parent 9af8fce commit 934d21e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
8 changes: 2 additions & 6 deletions metasfresh-webui-api.launch
Expand Up @@ -6,13 +6,9 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;metasfresh-webui-api&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER&quot; path=&quot;3&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="de.metas.ui.web.WebRestApiApplication"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="metasfresh-webui-api"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
Expand Down
Expand Up @@ -15,6 +15,7 @@
import org.adempiere.model.InterfaceWrapperHelper;
import org.compiere.model.I_M_PriceList;
import org.compiere.model.I_M_Product;
import org.slf4j.Logger;

import java.util.Objects;
import com.google.common.collect.ImmutableList;
Expand All @@ -33,6 +34,7 @@
import de.metas.i18n.ITranslatableString;
import de.metas.i18n.TranslatableStrings;
import de.metas.lang.SOTrx;
import de.metas.logging.LogManager;
import de.metas.money.CurrencyId;
import de.metas.pricing.PriceListVersionId;
import de.metas.pricing.ProductPriceId;
Expand Down Expand Up @@ -79,6 +81,8 @@

public final class ProductsProposalRowsLoader
{
private static final Logger logger = LogManager.getLogger(ProductsProposalRowsLoader.class);

// services
private final IPriceListDAO priceListsRepo = Services.get(IPriceListDAO.class);
private final IAttributeSetInstanceBL attributeSetInstanceBL = Services.get(IAttributeSetInstanceBL.class);
Expand Down Expand Up @@ -126,15 +130,16 @@ private ProductsProposalRowsLoader(
public ProductsProposalRowsData load()
{
List<ProductsProposalRow> rows = loadRows();
logger.debug("loaded {} productsProposalRows for priceListVersionIds={}", rows.size(), priceListVersionIds);
rows = updateLastShipmentDays(rows);

final PriceListVersionId singlePriceListVersionId = priceListVersionIds.size() == 1 ? priceListVersionIds.iterator().next() : null;
final PriceListVersionId basePriceListVersionId;
if (singlePriceListVersionId != null)
{
final ZonedDateTime datePromised = order == null? SystemTime.asZonedDateTime() : order.getDatePromised();

final ZonedDateTime datePromised = order == null ? SystemTime.asZonedDateTime() : order.getDatePromised();
basePriceListVersionId = priceListsRepo.getBasePriceListVersionIdForPricingCalculationOrNull(singlePriceListVersionId, datePromised);
logger.debug("singlePriceListVersionId={} and datePromised={}; -> basePriceListVersionId={}", PriceListVersionId.toRepoId(singlePriceListVersionId), datePromised, PriceListVersionId.toRepoId(basePriceListVersionId));
}
else
{
Expand All @@ -146,6 +151,7 @@ public ProductsProposalRowsData load()

if (order != null)
{
logger.debug("order!=null; -> add bpartnerName={} to headerProperties", order.getBpartnerName());
headerProperties.entry(ViewHeaderProperty.builder()
.caption(msgBL.translatable("C_BPartner_ID"))
.value(order.getBpartnerName())
Expand Down
Expand Up @@ -4,11 +4,13 @@
import java.util.function.Supplier;

import org.adempiere.util.lang.impl.TableRecordReference;
import org.slf4j.Logger;

import com.google.common.collect.ImmutableList;

import de.metas.bpartner.product.stats.BPartnerProductStatsService;
import de.metas.i18n.ITranslatableString;
import de.metas.logging.LogManager;
import de.metas.pricing.PriceListVersionId;
import de.metas.process.RelatedProcessDescriptor;
import de.metas.ui.web.order.products_proposal.filters.ProductsProposalViewFilter;
Expand Down Expand Up @@ -52,6 +54,8 @@
@ViewFactory(windowId = BasePLVProductsProposalViewFactory.WINDOW_ID_STRING)
public class BasePLVProductsProposalViewFactory extends ProductsProposalViewFactoryTemplate
{
private static final Logger logger = LogManager.getLogger(BasePLVProductsProposalViewFactory.class);

public static final String WINDOW_ID_STRING = "basePLVProductsProposal";
public static final WindowId WINDOW_ID = WindowId.fromJson(WINDOW_ID_STRING);

Expand Down Expand Up @@ -101,6 +105,7 @@ public final ProductsProposalView createView(@NonNull final ProductsProposalView
.soTrx(parentView.getSoTrx())
//
.build().load();
logger.debug("loaded ProductsProposalRowsData with size={} for basePriceListVersionId={}", basePriceListVersionId, rowsData.size());

final ProductsProposalView view = ProductsProposalView.builder()
.windowId(getWindowId())
Expand Down
Expand Up @@ -283,7 +283,7 @@ private boolean isExecuted()
return executed;
}

/* package */ final void assertNotExecuted()
/* package */ void assertNotExecuted()
{
if (isExecuted())
{
Expand All @@ -310,10 +310,11 @@ public ProcessInstanceResult startProcess(@NonNull final ProcessExecutionContext
{
executed = false;
}
logger.debug("executionResult.success={} executionResult.summary={}", executionResult.isSuccess(), executionResult.getSummary());
return executionResult;
}

private final ProcessInstanceResult executeADProcess(@NonNull final ProcessExecutionContext context)
private ProcessInstanceResult executeADProcess(@NonNull final ProcessExecutionContext context)
{
//
// Create the process info and execute the process synchronously
Expand All @@ -323,7 +324,7 @@ private final ProcessInstanceResult executeADProcess(@NonNull final ProcessExecu
.setPInstanceId(PInstanceId.ofRepoId(getInstanceId().toInt()))
.setTitle(caption.translate(context.getAdLanguage()))
.setPrintPreview(true)
.setJRDesiredOutputType( getTargetOutputType() )
.setJRDesiredOutputType(getTargetOutputType())
//
// Execute the process/report
.buildAndPrepareExecution()
Expand Down Expand Up @@ -354,7 +355,7 @@ private final ProcessInstanceResult executeADProcess(@NonNull final ProcessExecu
return saved;
}

/* package */ final IAutoCloseable lockForReading()
/* package */ IAutoCloseable lockForReading()
{
final ReadLock readLock = readwriteLock.readLock();
logger.debug("Acquiring read lock for {}: {}", this, readLock);
Expand All @@ -367,7 +368,7 @@ private final ProcessInstanceResult executeADProcess(@NonNull final ProcessExecu
};
}

/* package */ final IAutoCloseable lockForWriting()
/* package */ IAutoCloseable lockForWriting()
{
final WriteLock writeLock = readwriteLock.writeLock();
logger.debug("Acquiring write lock for {}: {}", this, writeLock);
Expand All @@ -381,24 +382,24 @@ private final ProcessInstanceResult executeADProcess(@NonNull final ProcessExecu
}

/**
* Try to get the target output type from the specific process param {@link de.metas.report.server.ReportConstants#REPORT_PARAM_REPORT_FORMAT},
* if the parameter is missing, the default output type is returned.
* @see OutputType#getDefault()
* Try to get the target output type from the specific process param {@link de.metas.report.server.ReportConstants#REPORT_PARAM_REPORT_FORMAT},
* if the parameter is missing, the default output type is returned.
*
* @see OutputType#getDefault()
*/
private OutputType getTargetOutputType()
{
final IDocumentFieldView formatField = parameters.getFieldViewOrNull(REPORT_PARAM_REPORT_FORMAT);

if ( formatField != null )
if (formatField != null)
{
final LookupValue outputTypeParamValue = formatField.getValueAs(LookupValue.class);

if (outputTypeParamValue != null)
{
final Optional<OutputType> targetOutputType =
OutputType.getOutputTypeByFileExtension( String.valueOf( formatField.getValueAs(LookupValue.class).getId() ) );
final Optional<OutputType> targetOutputType = OutputType.getOutputTypeByFileExtension(String.valueOf(formatField.getValueAs(LookupValue.class).getId()));

if ( targetOutputType.isPresent() )
if (targetOutputType.isPresent())
{
return targetOutputType.get();
}
Expand Down
Expand Up @@ -308,6 +308,7 @@ private ResultAction createResultAction(final ProcessInfo processInfo, final Pro
// Open report
if (reportTempFile != null)
{
logger.debug("The processExecutionResult specifies reportTempFile={}", reportTempFile);
return OpenReportAction.builder()
.filename(processExecutionResult.getReportFilename())
.contentType(processExecutionResult.getReportContentType())
Expand All @@ -318,6 +319,7 @@ private ResultAction createResultAction(final ProcessInfo processInfo, final Pro
// Create & open view from Records
else if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.GridView)
{
logger.debug("The processExecutionResult specifies recordsToOpen={}", recordsToOpen);
final Set<DocumentPath> referencingDocumentPaths = recordsToOpen.isAutomaticallySetReferencingDocumentPaths()
? extractReferencingDocumentPaths(processInfo)
: null;
Expand All @@ -336,6 +338,8 @@ else if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.GridVi
else if (processExecutionResult.getWebuiViewToOpen() != null)
{
final WebuiViewToOpen viewToOpen = processExecutionResult.getWebuiViewToOpen();
logger.debug("The processExecutionResult specifies viewToOpen={}", viewToOpen);

final ViewOpenTarget target = viewToOpen.getTarget();
if (ViewOpenTarget.IncludedView.equals(target))
{
Expand Down

0 comments on commit 934d21e

Please sign in to comment.