Skip to content

Commit

Permalink
Pull request #386: Bug fix: physical flows cannot be created unless e…
Browse files Browse the repository at this point in the history
…xternal id is explicity set

Merge in WALTZ/waltz from WALTZ/waltz-jws:CTCTOWALTZ-3261-physical-flow-creation-error-7107 to db-feature/waltz-7107-phys-flow-creation-bug-ext-id-null

* commit 'ec54a80fe873038c1524e167850c85c0e1e131d5':
  Bug fix: physical flows cannot be created unless external id is explicity set
  • Loading branch information
jessica-woodland-scott-db committed Jul 11, 2024
2 parents 9a8d5e2 + ec54a80 commit fdfd3e8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class LogicalFlowDao {

return ImmutableLogicalFlow.builder()
.id(record.getId())
.externalId(Optional.ofNullable(record.getExternalId()))
.externalId(record.getExternalId())
.source(ImmutableEntityReference.builder()
.kind(EntityKind.valueOf(record.getSourceEntityKind()))
.id(record.getSourceEntityId())
Expand Down Expand Up @@ -151,6 +151,7 @@ public class LogicalFlowDao {
record.setCreatedBy(flow.created().map(UserTimestamp::by).orElse(flow.lastUpdatedBy()));
record.setIsReadonly(flow.isReadOnly());
record.setIsRemoved(flow.isRemoved());
flow.externalId().ifPresent(record::setExternalId);
return record;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class PhysicalFlowDao {
.lastAttestedBy(Optional.ofNullable(record.getLastAttestedBy()))
.lastAttestedAt(Optional.ofNullable(record.getLastAttestedAt()).map(Timestamp::toLocalDateTime))
.isRemoved(record.getIsRemoved())
.externalId(Optional.ofNullable(record.getExternalId()))
.externalId(record.getExternalId())
.entityLifecycleStatus(EntityLifecycleStatus.valueOf(record.getEntityLifecycleStatus()))
.created(UserTimestamp.mkForUser(record.getCreatedBy(), record.getCreatedAt()))
.isReadOnly(record.getIsReadonly())
Expand Down Expand Up @@ -322,7 +322,8 @@ public long create(PhysicalFlow flow) {
record.setLastAttestedAt(flow.lastAttestedAt().map(Timestamp::valueOf).orElse(null));
record.setIsRemoved(flow.isRemoved());
record.setProvenance("waltz");
record.setExternalId(flow.externalId().orElse(null));

flow.externalId().ifPresent(record::setExternalId);

record.setCreatedAt(flow.created().map(UserTimestamp::atTimestamp).orElse(Timestamp.valueOf(flow.lastUpdatedAt())));
record.setCreatedBy(flow.created().map(UserTimestamp::by).orElse(flow.lastUpdatedBy()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ public Long create(PhysicalSpecification specification) {
record.setOwningEntityId(specification.owningEntity().id());

record.setName(specification.name());
record.setExternalId(specification.externalId().orElse(""));
record.setDescription(specification.description());
record.setFormat(specification.format().value());
record.setLastUpdatedAt(Timestamp.valueOf(specification.lastUpdatedAt()));
Expand All @@ -232,6 +231,8 @@ public Long create(PhysicalSpecification specification) {
record.setCreatedBy(specification.created().get().by());
record.setIsReadonly(specification.isReadOnly());

specification.externalId().ifPresent(record::setExternalId);

record.store();
return record.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
description: $physicalSpecification.description,
format: $physicalSpecification.format,
lastUpdatedBy: "waltz",
externalId: $physicalSpecification.externalId,
externalId: !_.isEmpty($physicalSpecification.externalId) ? $physicalSpecification.externalId : null,
id: $physicalSpecification.id ? $physicalSpecification.id : null
}
Expand All @@ -73,7 +73,7 @@
basisOffset: $physicalFlow.basisOffset,
criticality: $physicalFlow.criticality,
description: $physicalFlow.description,
externalId: $physicalFlow.externalId
externalId: !_.isEmpty($physicalFlow.externalId) ? $physicalFlow.externalId : null
}
const command = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
workingCopy = Object.assign({}, $physicalSpecification);
} else {
workingCopy = {
externalId: "",
externalId: null,
description: "",
format: null,
name: ""
Expand Down

0 comments on commit fdfd3e8

Please sign in to comment.