Skip to content

Commit

Permalink
#1055-api - Include internalName in JSONDocumentAction
Browse files Browse the repository at this point in the history
add internalName fields to various process descriptors

Include internalName in JSONDocumentAction #1055
  • Loading branch information
metas-ts committed Sep 25, 2018
1 parent 54bf276 commit 0452769
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 38 deletions.
Expand Up @@ -144,6 +144,7 @@ private WebuiHUProcessDescriptor toWebuiHUProcessDescriptor(@NonNull final HUPro
.huProcessDescriptor(huProcessDescriptor)
.processDescriptor(ProcessDescriptor.builder()
.setProcessId(processId)
.setInternalName(huProcessDescriptor.getInternalName())
.setType(ProcessDescriptorType.Report)
.setParametersDescriptor(parametersDescriptor)
.setLayout(ProcessLayout.builder()
Expand Down
Expand Up @@ -36,7 +36,7 @@

/**
* Unifies different descriptors.
*
*
* @author metas-dev <dev@metasfresh.com>
*/
@Value
Expand Down Expand Up @@ -69,6 +69,7 @@ public WebuiRelatedProcessDescriptor toWebuiRelatedProcessDescriptor()
{
return WebuiRelatedProcessDescriptor.builder()
.processId(processDescriptor.getProcessId())
.internalName(processDescriptor.getInternalName())
.processCaption(processDescriptor.getCaption())
.processDescription(processDescriptor.getDescription())
.quickAction(true)
Expand Down
Expand Up @@ -83,7 +83,7 @@

/**
* Creates {@link ProcessDescriptor}s from {@link I_AD_Process} based processes
*
*
* @author metas-dev <dev@metasfresh.com>
*
*/
Expand Down Expand Up @@ -134,6 +134,7 @@ private WebuiRelatedProcessDescriptor toWebuiRelatedProcessDescriptor(@NonNull f

return WebuiRelatedProcessDescriptor.builder()
.processId(processDescriptor.getProcessId())
.internalName(processDescriptor.getInternalName())
.processCaption(processDescriptor.getCaption())
.processDescription(processDescriptor.getDescription())
.debugProcessClassname(processDescriptor.getProcessClassname())
Expand Down Expand Up @@ -196,6 +197,7 @@ private ProcessDescriptor retrieveProcessDescriptor(final ProcessId processId)
// Process descriptor
return ProcessDescriptor.builder()
.setProcessId(processId)
.setInternalName(adProcess.getValue())
.setType(extractType(adProcess))
.setProcessClassname(extractClassnameOrNull(adProcess))
.setParametersDescriptor(parametersDescriptor)
Expand Down
Expand Up @@ -20,6 +20,8 @@
import de.metas.ui.web.process.ProcessId;
import de.metas.ui.web.window.descriptor.DocumentEntityDescriptor;
import de.metas.util.Check;
import lombok.Getter;
import lombok.NonNull;

/*
* #%L
Expand Down Expand Up @@ -57,7 +59,12 @@ public static enum ProcessDescriptorType
Form, Workflow, Process, Report
};

@Getter
private final ProcessId processId;

@Getter
private final String internalName;

private final ProcessDescriptorType type;
private final Class<? extends IProcessDefaultParametersProvider> defaultParametersProviderClass;
private final String processClassname;
Expand All @@ -69,9 +76,10 @@ public static enum ProcessDescriptorType
private static final Supplier<ETag> nextETagSupplier = ETagAware.newETagGenerator();
private final ETag eTag = nextETagSupplier.get();

private ProcessDescriptor(final Builder builder)
private ProcessDescriptor(@NonNull final Builder builder)
{
processId = builder.getProcessId();
internalName = builder.getInternalName();
type = builder.getType();

processClassname = builder.getProcessClassname();
Expand All @@ -90,11 +98,6 @@ public String toString()
.toString();
}

public ProcessId getProcessId()
{
return processId;
}

@Override
public ETag getETag()
{
Expand Down Expand Up @@ -185,6 +188,9 @@ public static final class Builder
private ProcessDescriptorType type;
private ProcessId processId;

@Getter
private String internalName;

private String processClassname;
private Optional<Class<?>> processClass = Optional.empty();

Expand All @@ -201,9 +207,9 @@ public ProcessDescriptor build()
return new ProcessDescriptor(this);
}

public Builder setProcessId(final ProcessId processId)
public Builder setInternalName(final String internalName)
{
this.processId = processId;
this.internalName = internalName;
return this;
}

Expand All @@ -213,6 +219,12 @@ private ProcessId getProcessId()
return processId;
}

public Builder setProcessId(final ProcessId processId)
{
this.processId = processId;
return this;
}

public Builder setType(final ProcessDescriptorType type)
{
this.type = type;
Expand Down
Expand Up @@ -13,6 +13,7 @@
import de.metas.i18n.ITranslatableString;
import de.metas.process.ProcessPreconditionsResolution;
import de.metas.ui.web.process.ProcessId;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;
import lombok.Value;
Expand Down Expand Up @@ -50,11 +51,21 @@
@ToString
public final class WebuiRelatedProcessDescriptor
{
@Getter
private final ProcessId processId;

@Getter
private final String internalName;

private final ITranslatableString processCaption;
private final ITranslatableString processDescription;

@Getter
private final boolean quickAction;

@Getter
private final boolean defaultQuickAction;

@NonNull
private final Supplier<ValueAndDuration<ProcessPreconditionsResolution>> preconditionsResolutionSupplier;

Expand All @@ -63,15 +74,16 @@ public final class WebuiRelatedProcessDescriptor
@lombok.Builder
private WebuiRelatedProcessDescriptor(
final ProcessId processId,
final String internalName,
final ITranslatableString processCaption,
final ITranslatableString processDescription,
final boolean quickAction,
final boolean defaultQuickAction,
@NonNull final Supplier<ProcessPreconditionsResolution> preconditionsResolutionSupplier,
final String debugProcessClassname)
{
super();
this.processId = processId;
this.internalName = internalName;
this.processCaption = processCaption;
this.processDescription = processDescription;
this.quickAction = quickAction;
Expand All @@ -84,11 +96,6 @@ private WebuiRelatedProcessDescriptor(
this.debugProcessClassname = debugProcessClassname;
}

public ProcessId getProcessId()
{
return processId;
}

public String getCaption(final String adLanguage)
{
final String captionOverride = getPreconditionsResolution().getCaptionOverrideOrNull(adLanguage);
Expand All @@ -105,16 +112,6 @@ public String getDescription(final String adLanguage)
return processDescription.translate(adLanguage);
}

public boolean isQuickAction()
{
return quickAction;
}

public boolean isDefaultQuickAction()
{
return defaultQuickAction;
}

private ProcessPreconditionsResolution getPreconditionsResolution()
{
return preconditionsResolutionSupplier.get().getValue();
Expand All @@ -141,7 +138,7 @@ public boolean isEnabledOrNotSilent()
final ProcessPreconditionsResolution preconditionsResolution = getPreconditionsResolution();
return preconditionsResolution.isAccepted() || !preconditionsResolution.isInternal();
}

public boolean isInternal()
{
final ProcessPreconditionsResolution preconditionsResolution = getPreconditionsResolution();
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/de/metas/ui/web/process/json/JSONDocumentAction.java
Expand Up @@ -16,6 +16,7 @@

import de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor;
import de.metas.ui.web.window.datatypes.json.JSONOptions;
import lombok.NonNull;

/*
* #%L
Expand Down Expand Up @@ -51,21 +52,27 @@ public final class JSONDocumentAction implements Serializable

@JsonProperty("processId")
private final String processId;

@JsonProperty("caption")
private final String caption;

@JsonProperty("description")
private final String description;

@JsonProperty("quickAction")
private final boolean quickAction;

@JsonProperty("defaultQuickAction")
private final boolean defaultQuickAction;

@JsonProperty("disabled")
@JsonInclude(JsonInclude.Include.NON_NULL)
private final Boolean disabled;

@JsonProperty("disabledReason")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private final String disabledReason;

@JsonProperty("disabledWithInternalReason")
@JsonInclude(JsonInclude.Include.NON_NULL)
private final Boolean disabledWithInternalReason; // exposed only for tracing/debugging
Expand All @@ -74,12 +81,16 @@ public final class JSONDocumentAction implements Serializable
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private final String evaluateDurationStr;

@JsonProperty("internalName")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private final String internalName;

private final Map<String, Object> debugProperties;

JSONDocumentAction(final WebuiRelatedProcessDescriptor relatedProcessDescriptor, final JSONOptions jsonOpts)
JSONDocumentAction(
@NonNull final WebuiRelatedProcessDescriptor relatedProcessDescriptor,
@NonNull final JSONOptions jsonOpts)
{
super();

final String adLanguage = jsonOpts.getAD_Language();

processId = relatedProcessDescriptor.getProcessId().toJson();
Expand All @@ -96,6 +107,8 @@ public final class JSONDocumentAction implements Serializable
final Duration preconditionsResolutionCalcDuration = relatedProcessDescriptor.getPreconditionsResolutionCalcDuration();
evaluateDurationStr = preconditionsResolutionCalcDuration != null ? TimeUtil.formatElapsed(preconditionsResolutionCalcDuration) : null;

internalName = relatedProcessDescriptor.getInternalName();

//
// Debug properties
if (jsonOpts.isProtocolDebugging())
Expand Down
Expand Up @@ -112,6 +112,7 @@ public ProcessDescriptor getProcessDescriptor(@NonNull final ProcessId processId

return ProcessDescriptor.builder()
.setProcessId(processId)
.setInternalName(actionId)
.setType(ProcessDescriptorType.Process)
//
.setLayout(processLayout)
Expand Down
Expand Up @@ -89,7 +89,6 @@ public static final JSONOptions of(final UserSession userSession)

private JSONOptions(final Builder builder)
{
super();
adLanguage = builder.getAD_Language();
showAdvancedFields = builder.isShowAdvancedFields();
dataFieldsListStr = Strings.emptyToNull(builder.dataFieldsListStr);
Expand Down
Expand Up @@ -515,7 +515,6 @@ public static final class Builder

private Builder()
{
super();
}

@Override
Expand Down
Expand Up @@ -7,6 +7,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

import org.adempiere.ad.expression.api.ConstantLogicExpression;
import org.adempiere.ad.expression.api.IExpression;
import org.adempiere.ad.expression.api.ILogicExpression;
Expand Down Expand Up @@ -98,10 +100,11 @@
// State
private final DocumentEntityDescriptor.Builder _documentEntryBuilder;

public GridTabVOBasedDocumentEntityDescriptorFactory(final GridTabVO gridTabVO,
final GridTabVO parentTabVO,
public GridTabVOBasedDocumentEntityDescriptorFactory(
@NonNull final GridTabVO gridTabVO,
@Nullable final GridTabVO parentTabVO,
final boolean isSOTrx,
final List<I_AD_UI_Element> labelsUIElements)
@NonNull final List<I_AD_UI_Element> labelsUIElements)
{
final boolean rootEntity = parentTabVO == null;

Expand Down Expand Up @@ -169,10 +172,11 @@ public DocumentEntityDescriptor.Builder documentEntity()
return _documentEntryBuilder;
}

private DocumentEntityDescriptor.Builder createDocumentEntityBuilder(final GridTabVO gridTabVO,
final GridTabVO parentTabVO,
private DocumentEntityDescriptor.Builder createDocumentEntityBuilder(
@NonNull final GridTabVO gridTabVO,
@Nullable final GridTabVO parentTabVO,
final boolean isSOTrx,
final List<I_AD_UI_Element> labelsUIElements)
@NonNull final List<I_AD_UI_Element> labelsUIElements)
{
final String tableName = gridTabVO.getTableName();

Expand Down

0 comments on commit 0452769

Please sign in to comment.