2
2
3
3
import java .util .EnumSet ;
4
4
import java .util .List ;
5
- import java .util .Objects ;
6
5
7
6
import org .camunda .bpm .engine .delegate .DelegateExecution ;
8
7
import org .hl7 .fhir .r4 .model .Bundle ;
13
12
import org .slf4j .Logger ;
14
13
import org .slf4j .LoggerFactory ;
15
14
16
- import ca . uhn . fhir . context . FhirContext ;
17
- import dev .dsf .bpe .ConstantsUpdateAllowList ;
18
- import dev .dsf .bpe .delegate .AbstractServiceDelegate ;
19
- import dev .dsf .fhir . authorization . read . ReadAccessHelper ;
15
+ import dev . dsf . bpe . ConstantsAllowList ;
16
+ import dev .dsf .bpe .v1 . ProcessPluginApi ;
17
+ import dev .dsf .bpe .v1 . activity .AbstractServiceDelegate ;
18
+ import dev .dsf .bpe . v1 . variables . Variables ;
20
19
import dev .dsf .fhir .client .FhirWebserviceClient ;
21
- import dev .dsf .fhir .client .FhirWebserviceClientProvider ;
22
- import dev .dsf .fhir .task .TaskHelper ;
23
20
import jakarta .ws .rs .WebApplicationException ;
24
21
25
22
public class DownloadAllowList extends AbstractServiceDelegate
26
23
{
27
24
private static final Logger logger = LoggerFactory .getLogger (DownloadAllowList .class );
28
25
29
- private final FhirContext context ;
30
-
31
- public DownloadAllowList (FhirWebserviceClientProvider clientProvider , TaskHelper taskHelper ,
32
- ReadAccessHelper readAccessHelper , FhirContext context )
26
+ public DownloadAllowList (ProcessPluginApi api )
33
27
{
34
- super (clientProvider , taskHelper , readAccessHelper );
35
-
36
- this .context = context ;
28
+ super (api );
37
29
}
38
30
39
31
@ Override
40
- public void afterPropertiesSet ( ) throws Exception
32
+ protected void doExecute ( DelegateExecution execution , Variables variables ) throws Exception
41
33
{
42
- super .afterPropertiesSet ();
43
- Objects .requireNonNull (context , "fhirContext" );
44
- }
45
-
46
- @ Override
47
- protected void doExecute (DelegateExecution execution ) throws Exception
48
- {
49
- Task task = getCurrentTaskFromExecutionVariables (execution );
34
+ Task task = variables .getStartTask ();
50
35
IdType bundleId = getBundleId (task );
51
- FhirWebserviceClient requesterClient = getFhirWebserviceClientProvider ()
36
+ FhirWebserviceClient requesterClient = api . getFhirWebserviceClientProvider ()
52
37
.getWebserviceClient (bundleId .getBaseUrl ());
53
38
54
39
Bundle bundle ;
@@ -75,8 +60,9 @@ protected void doExecute(DelegateExecution execution) throws Exception
75
60
76
61
try
77
62
{
78
- logger .debug ("Posting bundle to local endpoint: {}" , context .newXmlParser ().encodeResourceToString (bundle ));
79
- getFhirWebserviceClientProvider ().getLocalWebserviceClient ().withMinimalReturn ().postBundle (bundle );
63
+ logger .debug ("Posting bundle to local endpoint: {}" ,
64
+ api .getFhirContext ().newXmlParser ().encodeResourceToString (bundle ));
65
+ api .getFhirWebserviceClientProvider ().getLocalWebserviceClient ().withMinimalReturn ().postBundle (bundle );
80
66
}
81
67
catch (Exception e )
82
68
{
@@ -89,28 +75,26 @@ protected void doExecute(DelegateExecution execution) throws Exception
89
75
90
76
private IdType getBundleId (Task task )
91
77
{
92
- List <Reference > bundleReferences = getTaskHelper ()
93
- .getInputParameterReferenceValues (task , ConstantsUpdateAllowList . CODESYSTEM_DSF_UPDATE_ALLOW_LIST ,
94
- ConstantsUpdateAllowList . CODESYSTEM_DSF_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST )
78
+ List <Reference > bundleReferences = api . getTaskHelper ()
79
+ .getInputParameterValues (task , ConstantsAllowList . CODESYSTEM_DSF_ALLOW_LIST ,
80
+ ConstantsAllowList . CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST , Reference . class )
95
81
.toList ();
96
82
97
83
if (bundleReferences .size () != 1 )
98
84
{
99
85
logger .error ("Task input parameter {} contains unexpected number of Bundle IDs, expected 1, got {}" ,
100
- ConstantsUpdateAllowList .CODESYSTEM_DSF_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST ,
101
- bundleReferences .size ());
86
+ ConstantsAllowList .CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST , bundleReferences .size ());
102
87
throw new RuntimeException (
103
- "Task input parameter " + ConstantsUpdateAllowList . CODESYSTEM_DSF_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST
88
+ "Task input parameter " + ConstantsAllowList . CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST
104
89
+ " contains unexpected number of Bundle IDs, expected 1, got " + bundleReferences .size ());
105
90
}
106
91
else if (!bundleReferences .get (0 ).hasReference ()
107
92
|| !bundleReferences .get (0 ).getReference ().contains ("/Bundle/" ))
108
93
{
109
94
logger .error ("Task input parameter {} has no Bundle reference" ,
110
- ConstantsUpdateAllowList .CODESYSTEM_DSF_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST );
111
- throw new RuntimeException (
112
- "Task input parameter " + ConstantsUpdateAllowList .CODESYSTEM_DSF_UPDATE_ALLOW_LIST_VALUE_ALLOW_LIST
113
- + " has no Bundle reference" );
95
+ ConstantsAllowList .CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST );
96
+ throw new RuntimeException ("Task input parameter "
97
+ + ConstantsAllowList .CODESYSTEM_DSF_ALLOW_LIST_VALUE_ALLOW_LIST + " has no Bundle reference" );
114
98
}
115
99
116
100
return new IdType (bundleReferences .get (0 ).getReference ());
0 commit comments