Skip to content

Commit

Permalink
#6024 add bpartnerName in the olcand json
Browse files Browse the repository at this point in the history
  • Loading branch information
metas-rc committed Jan 10, 2020
1 parent 035c779 commit 300edd6
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 3 deletions.
Expand Up @@ -13,6 +13,7 @@
import org.adempiere.ad.table.RecordChangeLogEntry;
import org.adempiere.ad.table.RecordChangeLogRepository;
import org.adempiere.exceptions.AdempiereException;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -146,6 +147,7 @@ public class JsonRetrieverService
.put(BPartnerLocation.ID, JsonResponseLocation.METASFRESH_ID)
.put(BPartnerLocation.ACTIVE, JsonResponseLocation.ACTIVE)
.put(BPartnerLocation.NAME, JsonResponseLocation.NAME)
.put(BPartnerLocation.BPARTNERNAME, JsonResponseLocation.BPARTNERNAME)
.put(BPartnerLocation.ADDRESS_1, JsonResponseLocation.ADDRESS_1)
.put(BPartnerLocation.ADDRESS_2, JsonResponseLocation.ADDRESS_2)
.put(BPartnerLocation.ADDRESS_3, JsonResponseLocation.ADDRESS_3)
Expand Down Expand Up @@ -368,6 +370,7 @@ private static JsonResponseLocation toJson(@NonNull final BPartnerLocation locat
return JsonResponseLocation.builder()
.active(location.isActive())
.name(location.getName())
.bpartnerName(location.getBpartnerName())
.address1(location.getAddress1())
.address2(location.getAddress2())
.address3(location.getAddress3())
Expand Down
Expand Up @@ -1049,6 +1049,16 @@ else if (isUpdateRemove)
location.setName(null);
}

// bpartnerName
if (!isEmpty(jsonBPartnerLocation.getBpartnerName(), true))
{
location.setBpartnerName(jsonBPartnerLocation.getBpartnerName().trim());
}
else if (isUpdateRemove)
{
location.setBpartnerName(null);
}

// address1
if (!isEmpty(jsonBPartnerLocation.getAddress1(), true))
{
Expand Down
Expand Up @@ -594,6 +594,8 @@ private void updateBPartnerLocationRecord(
bpLocationRecord.setIsShipTo(true);
bpLocationRecord.setIsBillTo(true);

bpLocationRecord.setBPartnerName(from.getBpartnerName());

bpLocationRecord.setGLN(from.getGln());
if (from.getExternalId() != null)
{
Expand Down Expand Up @@ -655,6 +657,7 @@ private JsonResponseLocation toJsonBPartnerLocation(@NonNull final I_C_BPartner_
.city(location.getCity())
.region(location.getRegionName())
.countryCode(countryCode)
.bpartnerName(record.getBPartnerName())
//
.active(record.isActive())
//
Expand Down
@@ -1,17 +1,16 @@
package de.metas.rest_api.bpartner.request;

import static de.metas.rest_api.bpartner.SwaggerDocConstants.PARENT_SYNC_ADVISE_DOC;

import javax.annotation.Nullable;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

import de.metas.rest_api.common.JsonExternalId;
import de.metas.rest_api.common.SyncAdvise;

import com.fasterxml.jackson.annotation.JsonProperty;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
Expand Down Expand Up @@ -56,6 +55,9 @@ public class JsonRequestLocation
@JsonInclude(Include.NON_EMPTY)
String name;

@JsonInclude(Include.NON_EMPTY)
String bpartnerName;

@JsonInclude(Include.NON_EMPTY)
String address1;

Expand Down Expand Up @@ -132,6 +134,7 @@ private JsonRequestLocation(
@JsonProperty("gln") @Nullable final String gln,
@JsonProperty("externalId") @Nullable final JsonExternalId externalId,
@JsonProperty("name") @Nullable final String name,
@JsonProperty("bpartnerName") @Nullable final String bpartnerName,
@JsonProperty("active") @Nullable final Boolean active,
@JsonProperty("address1") @Nullable final String address1,
@JsonProperty("address2") @Nullable final String address2,
Expand All @@ -154,6 +157,8 @@ private JsonRequestLocation(

this.name = name;

this.bpartnerName = bpartnerName;

this.active = active;

this.address1 = address1;
Expand Down
Expand Up @@ -43,6 +43,7 @@ public class JsonResponseLocation
public static final String METASFRESH_ID = "metasfreshId";
public static final String EXTERNAL_ID = "externalId";
public static final String NAME = "name";
public static final String BPARTNERNAME = "bpartnerName";
public static final String ADDRESS_1 = "address1";
public static final String ADDRESS_2 = "address2";
public static final String ADDRESS_3 = "address3";
Expand Down Expand Up @@ -76,6 +77,9 @@ public class JsonResponseLocation
@ApiModelProperty(allowEmptyValue = false)
String name;

@ApiModelProperty(allowEmptyValue = false)
String bpartnerName;

@JsonInclude(Include.NON_EMPTY)
String address1;

Expand Down Expand Up @@ -128,6 +132,7 @@ private JsonResponseLocation(
@JsonProperty(METASFRESH_ID) @NonNull final MetasfreshId metasfreshId,
@JsonProperty(EXTERNAL_ID) @Nullable final JsonExternalId externalId,
@JsonProperty(NAME) @Nullable final String name,
@JsonProperty(BPARTNERNAME) @Nullable final String bpartnerName,
@JsonProperty(ACTIVE) @NonNull final Boolean active,
@JsonProperty(ADDRESS_1) @Nullable final String address1,
@JsonProperty(ADDRESS_2) @Nullable final String address2,
Expand Down Expand Up @@ -155,6 +160,8 @@ private JsonResponseLocation(

this.name = name;

this.bpartnerName = bpartnerName;

this.address1 = address1;
this.address2 = address2;
this.address3 = address3;
Expand Down
Expand Up @@ -57,6 +57,7 @@ public class BPartnerLocation
public static final String EXTERNAL_ID = "externalId";
public static final String GLN = "gln";
public static final String NAME = "name";
public static final String BPARTNERNAME = " bpartnerName";
public static final String ACTIVE = "active";
public static final String ADDRESS_1 = "address1";
public static final String ADDRESS_2 = "address2";
Expand All @@ -78,6 +79,8 @@ public class BPartnerLocation

private String name;

private String bpartnerName;

private boolean active;

private String address1;
Expand Down Expand Up @@ -121,6 +124,7 @@ private BPartnerLocation(
@Nullable final GLN gln,
@Nullable final Boolean active,
@Nullable final String name,
@Nullable final String bpartnerName,
@Nullable final String address1,
@Nullable final String address2,
@Nullable final String address3,
Expand All @@ -142,6 +146,8 @@ private BPartnerLocation(
this.active = coalesce(active, true);

this.name = name;

this.bpartnerName = bpartnerName;
this.address1 = address1;
this.address2 = address2;
this.address3 = address3;
Expand Down Expand Up @@ -216,6 +222,15 @@ public void setName(@Nullable final String name)
this.name = name;
}

public void setBpartnerName(@Nullable final String bpartnerName)
{
if (!Objects.equals(this.bpartnerName, bpartnerName))
{
createOriginalIfNotExists();
}
this.bpartnerName = bpartnerName;
}

public void setActive(@Nullable final boolean active)
{
if (!Objects.equals(this.active, active))
Expand Down
Expand Up @@ -177,6 +177,7 @@ private void saveBPartnerLocation(
bpartnerLocationRecord.setIsActive(bpartnerLocation.isActive());
bpartnerLocationRecord.setC_BPartner_ID(bpartnerId.getRepoId());
bpartnerLocationRecord.setName(bpartnerLocation.getName());
bpartnerLocationRecord.setBPartnerName(bpartnerLocation.getBpartnerName());

final BPartnerLocationType locationType = bpartnerLocation.getLocationType();
if (locationType != null)
Expand Down
Expand Up @@ -115,6 +115,7 @@ final class ChangeLogUtil
.put(I_C_BPartner_Location.COLUMNNAME_GLN, BPartnerLocation.GLN)
.put(I_C_BPartner_Location.COLUMNNAME_C_BPartner_Location_ID, BPartnerLocation.ID)
.put(I_C_BPartner_Location.COLUMNNAME_Name, BPartnerLocation.NAME)
.put(I_C_BPartner_Location.COLUMNNAME_BPartnerName, BPartnerLocation.BPARTNERNAME)
.put(I_C_BPartner_Location.COLUMNNAME_IsBillToDefault, BPartnerLocationType.BILL_TO_DEFAULT)
.put(I_C_BPartner_Location.COLUMNNAME_IsBillTo, BPartnerLocationType.BILL_TO)
.put(I_C_BPartner_Location.COLUMNNAME_IsShipToDefault, BPartnerLocationType.SHIP_TO_DEFAULT)
Expand Down

0 comments on commit 300edd6

Please sign in to comment.