11package dev .dsf .bpe .listener ;
22
3+ import static dev .dsf .bpe .PingProcessPluginDefinition .RESOURCE_VERSION ;
4+
35import java .util .List ;
46import java .util .Map ;
57import java .util .Objects ;
2022import org .springframework .beans .factory .InitializingBean ;
2123
2224import dev .dsf .bpe .ConstantsPing ;
23- import dev .dsf .bpe .PingProcessPluginDefinition ;
2425import dev .dsf .bpe .v1 .ProcessPluginApi ;
2526import dev .dsf .bpe .v1 .ProcessPluginDeploymentStateListener ;
2627import dev .dsf .fhir .client .FhirWebserviceClient ;
@@ -66,13 +67,14 @@ private void updateDraftTaskResources()
6667 {
6768 FhirWebserviceClient client = api .getFhirWebserviceClientProvider ().getLocalWebserviceClient ();
6869
69- List <String > draftTaskResourceProfiles = List .of ("http://dsf.dev/fhir/StructureDefinition/task-start-ping" ,
70- "http://dsf.dev/fhir/StructureDefinition/task-start-ping-autostart" );
70+ String pingProcessPrefix = "http://dsf.dev/bpe/Process/ping/" + RESOURCE_VERSION ;
71+ List <String > draftTaskResourceIdentifiers = List .of (pingProcessPrefix + "/task-start-ping" ,
72+ pingProcessPrefix + "task-start-ping-autostart" );
7173
72- for (String profile : draftTaskResourceProfiles )
74+ for (String identifier : draftTaskResourceIdentifiers )
7375 {
74- Optional <Task > optionalTask = searchTask (profile , PingProcessPluginDefinition . RESOURCE_VERSION ).getEntry ()
75- .stream (). map (Bundle .BundleEntryComponent ::getResource ).map (Task .class ::cast ).findFirst ();
76+ Optional <Task > optionalTask = searchTask (identifier ).getEntry (). stream ()
77+ .map (Bundle .BundleEntryComponent ::getResource ).map (Task .class ::cast ).findFirst ();
7678
7779 if (optionalTask .isPresent ())
7880 {
@@ -88,7 +90,7 @@ private void adaptDraftTask(Task task)
8890 Coding downloadResourceSizeBytesCoding = new Coding ();
8991 downloadResourceSizeBytesCoding .setSystem (dev .dsf .bpe .CodeSystem .DsfPing .URL )
9092 .setCode (dev .dsf .bpe .CodeSystem .DsfPing .Code .DOWNLOAD_RESOURCE_SIZE_BYTES .getValue ())
91- .setVersion (PingProcessPluginDefinition . RESOURCE_VERSION );
93+ .setVersion (RESOURCE_VERSION );
9294
9395 Optional <Task .ParameterComponent > optInput = api .getTaskHelper ().getFirstInputParameter (task ,
9496 downloadResourceSizeBytesCoding , DecimalType .class );
@@ -103,7 +105,7 @@ private void adaptDraftTask(Task task)
103105 Coding pongTimeoutDurationCoding = new Coding ();
104106 pongTimeoutDurationCoding .setSystem (dev .dsf .bpe .CodeSystem .DsfPing .URL )
105107 .setCode (dev .dsf .bpe .CodeSystem .DsfPing .Code .PONG_TIMEOUT_DURATION_ISO_8601 .getValue ())
106- .setVersion (PingProcessPluginDefinition . RESOURCE_VERSION );
108+ .setVersion (RESOURCE_VERSION );
107109
108110 optInput = api .getTaskHelper ().getFirstInputParameter (task , pongTimeoutDurationCoding , StringType .class );
109111 if (optInput .isEmpty ())
@@ -135,10 +137,10 @@ private Bundle search(Class<? extends Resource> type, String url)
135137 Map .of ("url" , List .of (url )));
136138 }
137139
138- private Bundle searchTask (String profile , String version )
140+ private Bundle searchTask (String identifier )
139141 {
140142 return api .getFhirWebserviceClientProvider ().getLocalWebserviceClient ().search (Task .class ,
141- Map .of ("_profile " , List .of (profile + "|" + version ), "status" , List .of ("draft" )));
143+ Map .of ("identifier " , List .of (identifier ), "status" , List .of ("draft" )));
142144 }
143145
144146 private <T extends MetadataResource > List <T > extractAndSortResources (Bundle bundle , Class <T > type , String url )
@@ -167,8 +169,7 @@ else if (version1.major < version2.major)
167169
168170 private boolean currentIsNewestResource (List <? extends MetadataResource > resources )
169171 {
170- return !resources .isEmpty () && PingProcessPluginDefinition .RESOURCE_VERSION
171- .equals (resources .get (resources .size () - 1 ).getVersion ());
172+ return !resources .isEmpty () && RESOURCE_VERSION .equals (resources .get (resources .size () - 1 ).getVersion ());
172173 }
173174
174175 private <T > Optional <T > getNewestResource (List <T > resources )
0 commit comments