2828import com .netgrif .application .engine .workflow .service .interfaces .IDataService ;
2929import com .netgrif .application .engine .workflow .service .interfaces .ITaskService ;
3030import com .netgrif .application .engine .workflow .service .interfaces .IWorkflowService ;
31+ import com .querydsl .core .types .Predicate ;
3132import lombok .RequiredArgsConstructor ;
3233import lombok .extern .slf4j .Slf4j ;
3334import org .springframework .data .domain .Page ;
@@ -194,9 +195,9 @@ public Case findMenuItem(String identifier) {
194195
195196 @ Override
196197 public Case findMenuItem (String identifier , boolean retry ) {
197- String query = String . format ( "processIdentifier:%s AND dataSet.%s.textValue.keyword: \" %s \" " ,
198- MenuProcessRunner .MENU_NET_IDENTIFIER , MenuItemConstants . FIELD_IDENTIFIER , identifier );
199- return findCase ( MenuProcessRunner . MENU_NET_IDENTIFIER , query );
198+ return findCase ( QCase . case$ . processIdentifier
199+ . eq ( MenuProcessRunner .MENU_NET_IDENTIFIER )
200+ . and ( QCase . case$ . dataSet . get ( MenuItemConstants . FIELD_IDENTIFIER ). value . eq ( identifier )) );
200201 }
201202
202203 /**
@@ -208,10 +209,10 @@ public Case findMenuItem(String identifier, boolean retry) {
208209 */
209210 @ Override
210211 public Case findMenuItem (String path , String name ) {
211- // TODO retry
212- String query = String . format ( "processIdentifier:%s AND title.keyword: \" %s \" AND nodePath: \" %s \" " ,
213- MenuProcessRunner . MENU_NET_IDENTIFIER , name , path );
214- return findCase ( MenuProcessRunner . MENU_NET_IDENTIFIER , query );
212+ return findCase ( QCase . case$ . processIdentifier
213+ . eq ( MenuProcessRunner . MENU_NET_IDENTIFIER )
214+ . and ( QCase . case$ . title . eq ( name ))
215+ . and ( QCase . case$ . dataSet . get ( MenuItemConstants . FIELD_NODE_PATH ). value . eq ( path )) );
215216 }
216217
217218 /**
@@ -223,9 +224,9 @@ public Case findMenuItem(String path, String name) {
223224 @ Override
224225 public Case findFolderCase (String path ) {
225226// TODO
226- String query = String . format ( "processIdentifier:%s AND dataSet.%s.textValue.keyword: \" %s \" " ,
227- MenuProcessRunner .MENU_NET_IDENTIFIER , MenuItemConstants . FIELD_NODE_PATH , path );
228- return findCase ( MenuProcessRunner . MENU_NET_IDENTIFIER , query );
227+ return findCase ( QCase . case$ . processIdentifier
228+ . eq ( MenuProcessRunner .MENU_NET_IDENTIFIER )
229+ . and ( QCase . case$ . dataSet . get ( MenuItemConstants . FIELD_NODE_PATH ). value . eq ( path )) );
229230 }
230231
231232 /**
@@ -384,6 +385,10 @@ public Case removeChildItemFromParent(String folderId, Case childItem) {
384385 return workflowService .save (parentFolder );
385386 }
386387
388+ protected Case findCase (Predicate predicate ) {
389+ return workflowService .searchOne (predicate );
390+ }
391+
387392 protected Case findCase (String processIdentifier , String query ) {
388393 CaseSearchRequest request = CaseSearchRequest .builder ()
389394 .process (Collections .singletonList (new CaseSearchRequest .PetriNet (processIdentifier )))
0 commit comments