Skip to content

Commit 23cedb7

Browse files
authored
Merge pull request #7342 from hmxlabs/7336-Phys-Flow-Search
#7336 Support Search for Physical Flows
2 parents 2aad08c + 612b6e9 commit 23cedb7

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

waltz-data/src/main/java/org/finos/waltz/data/physical_flow/PhysicalFlowDao.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
package org.finos.waltz.data.physical_flow;
2020

2121
import org.finos.waltz.data.InlineSelectFieldFactory;
22+
import org.finos.waltz.data.JooqUtilities;
23+
import org.finos.waltz.data.SearchUtilities;
2224
import org.finos.waltz.data.enum_value.EnumValueDao;
2325
import org.finos.waltz.model.EntityKind;
2426
import org.finos.waltz.model.EntityLifecycleStatus;
2527
import org.finos.waltz.model.EntityReference;
2628
import org.finos.waltz.model.UserTimestamp;
29+
import org.finos.waltz.model.entity_search.EntitySearchOptions;
2730
import org.finos.waltz.model.enum_value.EnumValueKind;
2831
import org.finos.waltz.model.physical_flow.CriticalityValue;
2932
import org.finos.waltz.model.physical_flow.FrequencyKindValue;
@@ -33,6 +36,7 @@
3336
import org.finos.waltz.model.physical_flow.PhysicalFlowInfo;
3437
import org.finos.waltz.model.physical_flow.PhysicalFlowParsed;
3538
import org.finos.waltz.model.physical_flow.TransportKindValue;
39+
import org.finos.waltz.schema.Tables;
3640
import org.finos.waltz.schema.tables.PhysicalSpecDataType;
3741
import org.finos.waltz.schema.tables.records.PhysicalFlowRecord;
3842
import org.jooq.Condition;
@@ -42,6 +46,7 @@
4246
import org.jooq.Record1;
4347
import org.jooq.RecordMapper;
4448
import org.jooq.Select;
49+
import org.jooq.SelectQuery;
4550
import org.jooq.TableField;
4651
import org.jooq.impl.DSL;
4752
import org.slf4j.Logger;
@@ -69,6 +74,7 @@
6974
import static org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW;
7075
import static org.finos.waltz.schema.tables.PhysicalFlow.PHYSICAL_FLOW;
7176
import static org.finos.waltz.schema.tables.PhysicalSpecification.PHYSICAL_SPECIFICATION;
77+
import static org.jooq.impl.DSL.select;
7278

7379

7480
@Repository
@@ -554,4 +560,46 @@ private int updateEnum(long flowId, TableField<PhysicalFlowRecord, String> field
554560
.where(PHYSICAL_FLOW.ID.eq(flowId))
555561
.execute();
556562
}
563+
564+
public List<PhysicalFlow> search(EntitySearchOptions options) {
565+
List<String> terms = SearchUtilities.mkTerms(options.searchQuery());
566+
if (terms.isEmpty()) {
567+
return newArrayList();
568+
}
569+
570+
boolean showRemoved = options
571+
.entityLifecycleStatuses()
572+
.contains(EntityLifecycleStatus.REMOVED);
573+
574+
Condition maybeFilterRemoved = showRemoved
575+
? DSL.trueCondition() // match anything
576+
: PHYSICAL_FLOW.IS_REMOVED.isFalse();
577+
578+
Condition likeName = JooqUtilities.mkBasicTermSearch(PHYSICAL_FLOW.NAME, terms);
579+
Condition likeDesc = JooqUtilities.mkBasicTermSearch(PHYSICAL_FLOW.DESCRIPTION, terms);
580+
Condition likeExternalIdentifier = JooqUtilities.mkStartsWithTermSearch(PHYSICAL_FLOW.EXTERNAL_ID, terms)
581+
.or(JooqUtilities.mkStartsWithTermSearch(EXTERNAL_IDENTIFIER.EXTERNAL_ID, terms));
582+
583+
Condition searchFilter = likeName.or(likeDesc).or(likeExternalIdentifier);
584+
585+
SelectQuery<Record> query = dsl
586+
.selectDistinct(PHYSICAL_FLOW.fields())
587+
.from(PHYSICAL_FLOW)
588+
.leftOuterJoin(EXTERNAL_IDENTIFIER)
589+
.on(EXTERNAL_IDENTIFIER.ENTITY_KIND.eq(EntityKind.PHYSICAL_FLOW.name())
590+
.and(EXTERNAL_IDENTIFIER.ENTITY_ID.eq(Tables.PHYSICAL_FLOW.ID)))
591+
.where(searchFilter)
592+
.and(maybeFilterRemoved)
593+
.orderBy(PHYSICAL_FLOW.NAME)
594+
.limit(options.limit())
595+
.getQuery();
596+
597+
return query.fetch(r -> {
598+
PhysicalFlow flow = PhysicalFlowDao.TO_DOMAIN_MAPPER.map(r);
599+
return ImmutablePhysicalFlow
600+
.copyOf(flow)
601+
.withDescription(flow.description());
602+
});
603+
}
604+
557605
}

waltz-model/src/main/java/org/finos/waltz/model/physical_flow/PhysicalFlow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public EntityReference entityReference() {
100100
.kind(EntityKind.PHYSICAL_FLOW)
101101
.id(id().get())
102102
.description(description())
103+
.externalId(externalId())
104+
.name(name())
103105
.build();
104106
}
105107

waltz-ng/client/navbar/components/nav-search-overlay/nav-search-overlay.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const initialState = {
4747
entity.MEASURABLE.key,
4848
entity.DATA_TYPE.key,
4949
entity.PHYSICAL_SPECIFICATION.key,
50+
entity.PHYSICAL_FLOW.key,
5051
entity.END_USER_APPLICATION.key,
5152
entity.LEGAL_ENTITY.key,
5253
entity.SERVER.key,
@@ -150,7 +151,7 @@ function controller($element,
150151
handleSearch(query, [entity.APPLICATION.key, entity.PERSON.key])
151152
.then(() => handleSearch(query, [entity.APP_GROUP.key, entity.CHANGE_INITIATIVE.key, entity.ORG_UNIT.key]))
152153
.then(() => handleSearch(query, [entity.ACTOR.key, entity.MEASURABLE.key, entity.LEGAL_ENTITY.key, entity.END_USER_APPLICATION.key]))
153-
.then(() => handleSearch(query, [entity.PHYSICAL_SPECIFICATION.key, entity.DATA_TYPE.key, entity.SERVER.key, entity.DATABASE.key]))
154+
.then(() => handleSearch(query, [entity.PHYSICAL_SPECIFICATION.key, entity.PHYSICAL_FLOW.key, entity.DATA_TYPE.key, entity.SERVER.key, entity.DATABASE.key]))
154155
.then(() => handleSearch(query, [entity.SOFTWARE.key, entity.ROADMAP.key, entity.LOGICAL_DATA_ELEMENT.key, entity.LICENCE.key]))
155156
.catch(e => displayError("Failed to search"))
156157
.finally(() => vm.searching = false);

waltz-service/src/main/java/org/finos/waltz/service/entity_search/EntitySearchService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.finos.waltz.service.orgunit.OrganisationalUnitService;
3434
import org.finos.waltz.service.person.PersonService;
3535
import org.finos.waltz.service.physical_specification.PhysicalSpecificationService;
36+
import org.finos.waltz.service.physical_flow.PhysicalFlowService;
3637
import org.finos.waltz.service.roadmap.RoadmapService;
3738
import org.finos.waltz.service.server_information.ServerInformationService;
3839
import org.finos.waltz.service.software_catalog.SoftwareCatalogService;
@@ -71,6 +72,7 @@ public class EntitySearchService {
7172
private final OrganisationalUnitService organisationalUnitService;
7273
private final PersonService personService;
7374
private final PhysicalSpecificationService physicalSpecificationService;
75+
private final PhysicalFlowService physicalFlowService;
7476
private final RoadmapService roadmapService;
7577
private final ServerInformationService serverInformationService;
7678
private final SoftwareCatalogService softwareCatalogService;
@@ -93,6 +95,7 @@ public EntitySearchService(DBExecutorPoolInterface dbExecutorPool,
9395
OrganisationalUnitService organisationalUnitService,
9496
PersonService personService,
9597
PhysicalSpecificationService physicalSpecificationService,
98+
PhysicalFlowService physicalFlowService,
9699
RoadmapService roadmapService,
97100
ServerInformationService serverInformationService,
98101
SoftwareCatalogService softwareCatalogService,
@@ -114,6 +117,7 @@ public EntitySearchService(DBExecutorPoolInterface dbExecutorPool,
114117
checkNotNull(organisationalUnitService, "organisationalUnitService cannot be null");
115118
checkNotNull(personService, "personService cannot be null");
116119
checkNotNull(physicalSpecificationService, "physicalSpecificationService cannot be null");
120+
checkNotNull(physicalFlowService, "physicalFlowService cannot be null");
117121
checkNotNull(roadmapService, "roadmapService cannot be null");
118122
checkNotNull(serverInformationService, "serverInformationService cannot be null");
119123
checkNotNull(softwareCatalogService, "softwareCatalogService cannot be null");
@@ -134,6 +138,7 @@ public EntitySearchService(DBExecutorPoolInterface dbExecutorPool,
134138
this.organisationalUnitService = organisationalUnitService;
135139
this.personService = personService;
136140
this.physicalSpecificationService = physicalSpecificationService;
141+
this.physicalFlowService = physicalFlowService;
137142
this.roadmapService = roadmapService;
138143
this.serverInformationService = serverInformationService;
139144
this.softwareCatalogService = softwareCatalogService;
@@ -198,6 +203,8 @@ private Callable<Collection<? extends WaltzEntity>> mkCallable(EntityKind entity
198203
return () -> personService.search(options);
199204
case PHYSICAL_SPECIFICATION:
200205
return () -> physicalSpecificationService.search(options);
206+
case PHYSICAL_FLOW:
207+
return () -> physicalFlowService.search(options);
201208
case ROADMAP:
202209
return () -> roadmapService.search(options);
203210
case SERVER:

waltz-service/src/main/java/org/finos/waltz/service/physical_flow/PhysicalFlowService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.finos.waltz.common.exception.InsufficientPrivelegeException;
2222
import org.finos.waltz.common.exception.ModifyingReadOnlyRecordException;
2323
import org.finos.waltz.common.exception.NotFoundException;
24+
import org.finos.waltz.model.entity_search.EntitySearchOptions;
2425
import org.finos.waltz.service.changelog.ChangeLogService;
2526
import org.finos.waltz.service.data_type.DataTypeDecoratorService;
2627
import org.finos.waltz.service.external_identifier.ExternalIdentifierService;
@@ -453,4 +454,8 @@ public void checkHasPermission(long flowId, String username) throws Insufficient
453454
checkLogicalFlowPermission(EntityReference.mkRef(EntityKind.LOGICAL_DATA_FLOW, physFlow.logicalFlowId()), username);
454455
}
455456

457+
public List<PhysicalFlow> search(EntitySearchOptions options) {
458+
checkNotNull(options, "Search options cannot be null");
459+
return physicalFlowDao.search(options);
460+
}
456461
}

0 commit comments

Comments
 (0)