Skip to content

Commit

Permalink
5364-app - Add Support for additional core fields
Browse files Browse the repository at this point in the history
fix NPE and improve error message
#5364
  • Loading branch information
metas-ts committed Jul 18, 2019
1 parent e5e78a7 commit 0255c62
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
Expand Up @@ -312,7 +312,10 @@ public BPartnerComposite persist(
{
if (effectiveSyncAdvise.isFailIfNotExists())
{
throw new MissingResourceException("bpartner");
throw new MissingResourceException(
"Did not find an existing partner with identifier '" + bpartnerIdentifierStr + "'",
jsonBPartnerComposite)
.setParameter("effectiveSyncAdvise", effectiveSyncAdvise);
}
// create new aggregation root
bpartnerComposite = BPartnerComposite.builder().build();
Expand Down Expand Up @@ -347,7 +350,9 @@ public BPartnerContact persist(
{
if (parentSyncAdvise.isFailIfNotExists())
{
throw new MissingResourceException("jsonContact");
throw new MissingResourceException(
"Did not find an existing contact with identifier '" + contactIdentifierStr + "'")
.setParameter("effectiveSyncAdvise", parentSyncAdvise);
}
if (jsonContact.getMetasfreshBPartnerId() == null)
{
Expand Down
Expand Up @@ -74,7 +74,8 @@ void init()
{
AdempiereTestHelper.get().init();

BPartnerCompositeRepository bpartnerCompositeRepository = new BPartnerCompositeRepository(new MockLogEntriesRepository());
final BPartnerCompositeRepository bpartnerCompositeRepository = new BPartnerCompositeRepository(new MockLogEntriesRepository());

final JsonServiceFactory jsonServiceFactory = new JsonServiceFactory(
bpartnerCompositeRepository,
new BPGroupRepository(),
Expand Down
Expand Up @@ -66,66 +66,66 @@ public class JsonResponseBPartner
MetasfreshId metasfreshId;

@ApiModelProperty( //
allowEmptyValue = true, //
required = false, //
dataType = "java.lang.String", //
value = "This translates to `C_BPartner.ExternalId`.")
@JsonInclude(Include.NON_NULL)
JsonExternalId externalId;

@ApiModelProperty(allowEmptyValue = false, value = "This translates to `C_BPartner.Value`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.Value`.")
String code;

@ApiModelProperty(allowEmptyValue = false, value = "This translates to `C_BPartner.IsActive`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.IsActive`.")
boolean active;

@ApiModelProperty(allowEmptyValue = false, value = "This translates to `C_BPartner.Name`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.Name`.")
String name;

@ApiModelProperty(allowEmptyValue = true, value = "This translates to `C_BPartner.Name2`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.Name2`.")
@JsonInclude(Include.NON_NULL)
String name2;

@ApiModelProperty(allowEmptyValue = true, value = "This translates to `C_BPartner.Name3`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.Name3`.")
@JsonInclude(Include.NON_NULL)
String name3;

@ApiModelProperty( //
allowEmptyValue = true, //
required = false, //
value = "This translates to `C_BPartner.CompanyName`.\n"
+ "If set, the the respective `C_BPartner` record will also have `IsCompany='Y'`")
@JsonInclude(Include.NON_NULL)
String companyName;

@ApiModelProperty( //
allowEmptyValue = true, //
required = false, //
value = "This translates to `C_BPartner.BPartner_Parent_ID`. It's a this bpartner's central/parent company",//
dataType = "java.lang.Integer")
@JsonInclude(Include.NON_NULL)
MetasfreshId parentId;

@ApiModelProperty( //
allowEmptyValue = true, //
required = false, //
value = "This translates to `C_BPartner.Phone2`. It's this bpartner's central phone number")
@JsonInclude(Include.NON_NULL)
String phone;

@JsonInclude(Include.NON_NULL)
String language;

@ApiModelProperty(allowEmptyValue = true, value = "This translates to `C_BPartner.URL`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.URL`.")
@JsonInclude(Include.NON_NULL)
String url;

@ApiModelProperty(allowEmptyValue = true, value = "This translates to `C_BPartner.URL2`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.URL2`.")
@JsonInclude(Include.NON_NULL)
private String url2;

@ApiModelProperty(allowEmptyValue = true, value = "This translates to `C_BPartner.URL3`.")
@ApiModelProperty(required = false, value = "This translates to `C_BPartner.URL3`.")
@JsonInclude(Include.NON_NULL)
private String url3;

@ApiModelProperty( //
allowEmptyValue = true, //
required = false, //
value = "Name of the business partner's group")
@JsonInclude(Include.NON_NULL)
String group;
Expand All @@ -138,7 +138,7 @@ public class JsonResponseBPartner
@Builder(toBuilder = true)
private JsonResponseBPartner(
@JsonProperty(METASFRESH_ID) @NonNull final MetasfreshId metasfreshId,
@JsonProperty(EXTERNAL_ID) @NonNull final JsonExternalId externalId,
@JsonProperty(EXTERNAL_ID) @Nullable final JsonExternalId externalId,
@JsonProperty(CODE) @NonNull final String code,
@JsonProperty(ACTIVE) @NonNull final Boolean active,
@JsonProperty(NAME) @NonNull final String name,
Expand Down

0 comments on commit 0255c62

Please sign in to comment.