3737import org .integratedmodelling .klab .rest .Notification ;
3838import org .integratedmodelling .klab .utils .JsonUtils ;
3939import org .integratedmodelling .klab .utils .NameGenerator ;
40- import org .integratedmodelling .klab .utils .Parameters ;
4140import org .integratedmodelling .klab .utils .Utils ;
4241
42+ import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
4343import com .fasterxml .jackson .annotation .JsonProperty ;
4444
4545import kong .unirest .HttpResponse ;
@@ -131,6 +131,7 @@ public String toString() {
131131
132132 }
133133
134+ @ JsonIgnoreProperties (ignoreUnknown = true )
134135 public static class Schema {
135136
136137 private String type = "number" ;
@@ -154,6 +155,7 @@ public void setSubtype(String subtype) {
154155
155156 }
156157
158+ @ JsonIgnoreProperties (ignoreUnknown = true )
157159 public static class Parameter {
158160
159161 private String name ;
@@ -303,6 +305,7 @@ public void setTitle(String title) {
303305 * A user defined OpenEO process. Can be used as a "namespace" when running a
304306 * job.
305307 */
308+ @ JsonIgnoreProperties (ignoreUnknown = true )
306309 public static class Process {
307310
308311 private String id ;
@@ -512,7 +515,7 @@ public Map<String, Object> getJobResults(Job job) {
512515 * @param budget
513516 * @return
514517 */
515- public String createRemoteJob (String processId , Parameters < String > parameters , Process ... processes ) {
518+ public String createRemoteJob (String processId , JSONObject parameters , Process ... processes ) {
516519
517520 Map <String , Object > request = new LinkedHashMap <>();
518521
@@ -548,7 +551,7 @@ public String createRemoteJob(String processId, Parameters<String> parameters, P
548551 * server side before the run and removed afterwards.
549552 */
550553 @ SuppressWarnings ("unchecked" )
551- public <T > T runJob (String processId , Parameters < String > parameters , IMonitor monitor , Class <T > resultClass ,
554+ public <T > T runJob (String processId , JSONObject parameters , IMonitor monitor , Class <T > resultClass ,
552555 Process ... namespace ) {
553556
554557 Map <String , Object > request = new LinkedHashMap <>();
@@ -581,17 +584,15 @@ public <T> T runJob(String processId, Parameters<String> parameters, IMonitor mo
581584 * is used in the namespace. Otherwise the process is stored at
582585 * server side before the run and removed afterwards.
583586 */
584- public void runJob (String processId , Parameters < String > parameters , IMonitor monitor ,
587+ public void runJob (String processId , JSONObject parameters , IMonitor monitor ,
585588 Consumer <InputStream > resultConsumer , Process ... namespace ) {
586589
587- Map <String , Object > request = new LinkedHashMap <>();
588-
589- request .put ("process" , createJobDefinition (processId , parameters , namespace ));
590- request .put ("plan" , plan );
591- request .put ("budget" , budget <= 0 ? null : budget );
590+ parameters .put ("process" , createJobDefinition (processId , parameters , namespace ));
591+ parameters .put ("plan" , plan );
592+ parameters .put ("budget" , budget <= 0 ? null : budget );
592593
593594 Unirest .post (endpoint + "/result" ).contentType ("application/json" ).socketTimeout (responseTimeoutMs )
594- .header ("Authorization" , authorization .getAuthorization ()).body (request ).thenConsume ((rawr ) -> {
595+ .header ("Authorization" , authorization .getAuthorization ()).body (parameters ).thenConsume ((rawr ) -> {
595596 boolean error = false ;
596597 if (rawr .getStatus () - 400 >= 0 ) {
597598 monitor .error (new KlabRemoteException ("Server returned error code " + rawr .getStatus ()));
@@ -632,14 +633,14 @@ private String getNamespaceUrl(Process udp) {
632633 * at server side before the run and removed afterwards.
633634 * @return
634635 */
635- private Map <String , Object > createJobDefinition (String processId , Parameters < String > parameters ,
636+ private Map <String , Object > createJobDefinition (String processId , JSONObject parameters ,
636637 Process ... namespace ) {
637638
638639 Map <String , Object > processGraph = new LinkedHashMap <>();
639640 Map <String , Object > processCall = new LinkedHashMap <>();
640641
641642 processCall .put ("process_id" , processId );
642- processCall .put ("arguments" , parameters == null ? new HashMap <>() : parameters .getData ());
643+ processCall .put ("arguments" , parameters == null ? new HashMap <>() : parameters .toMap ());
643644 processCall .put ("result" , true );
644645
645646 if (namespace != null ) {
@@ -723,7 +724,7 @@ public void startJob(String jobId, IMonitor monitor, Consumer<Map<String, Object
723724 * afterwards.
724725 * @return
725726 */
726- public boolean submit (String processId , Parameters < String > parameters , IMonitor monitor ,
727+ public boolean submit (String processId , JSONObject parameters , IMonitor monitor ,
727728 Consumer <Map <String , Object >> resultHandler , BiConsumer <String , String > errorHandler ,
728729 Process ... namespace ) {
729730
@@ -745,12 +746,12 @@ public boolean submit(String processId, Parameters<String> parameters, IMonitor
745746 * @param namespace
746747 * @return
747748 */
748- public OpenEOFuture submit (String processId , Parameters < String > parameters , IMonitor monitor ,
749+ public OpenEOFuture submit (String processId , JSONObject parameters , IMonitor monitor ,
749750 Process ... namespace ) {
750751 return new OpenEOFuture (processId , parameters , monitor , namespace );
751752 }
752753
753- public boolean validateProcess (Process process , Parameters < String > parameters ,
754+ public boolean validateProcess (Process process , JSONObject parameters ,
754755 BiConsumer <String , String > errorHandler ) {
755756
756757 HttpResponse <JsonNode > response = Unirest .post (endpoint + "/validation" ).contentType ("application/json" )
@@ -862,7 +863,7 @@ public class OpenEOFuture implements Future<Map<String, Object>> {
862863 AtomicBoolean canceled = new AtomicBoolean (false );
863864 String error ;
864865
865- public OpenEOFuture (String processId , Parameters < String > parameters , IMonitor monitor , Process ... namespace ) {
866+ public OpenEOFuture (String processId , JSONObject parameters , IMonitor monitor , Process ... namespace ) {
866867 this .processId = processId ;
867868 String jobId = createRemoteJob (processId , parameters , namespace );
868869 if (jobId == null ) {
0 commit comments