You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2022/01/09 22:37:09 UTC
[camel-karavan] branch main updated: Karavan-core cleanup (#154)
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new dabeeac Karavan-core cleanup (#154)
dabeeac is described below
commit dabeeacaef6424a92101d12ea49ff088ed4b3551
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Sun Jan 9 17:37:03 2022 -0500
Karavan-core cleanup (#154)
---
.github/workflows/main.yml | 4 +-
karavan-core/src/core/api/CamelApi.ts | 1550 +++++++++-----------
karavan-core/src/core/api/CamelApiExt.ts | 24 +-
karavan-core/src/core/api/CamelUi.ts | 7 +-
karavan-core/src/core/api/CamelUtil.ts | 87 ++
karavan-core/src/core/api/CamelYaml.ts | 47 +-
karavan-core/src/core/api/CamelYamlSteps.ts | 848 +++++++++++
karavan-core/src/core/model/CamelModel.ts | 641 +-------
karavan-core/test/addStep.spec.ts | 45 +
karavan-core/test/clone.spec.ts | 84 ++
.../integration.spec.ts => getToSteps.spec.ts} | 26 +-
karavan-core/test/getToSteps.yaml | 36 +
.../test/{camel_yaml => }/integration.spec.ts | 4 +-
.../test/{camel_yaml => }/integration1.yaml | 6 +-
karavan-core/test/new-api.spec.ts | 51 +
karavan-core/test/{camel_yaml => }/plain.spec.ts | 6 +-
.../test/{camel_yaml/route1.yaml => plain1.yaml} | 6 +-
karavan-core/test/tsconfig.testing.json | 8 +-
karavan-core/test/updateStep.spec.ts | 63 +
karavan-core/tsconfig.json | 3 +-
karavan-designer/package.json | 1 +
karavan-designer/src/App.tsx | 2 +-
karavan-designer/src/designer/DslConnections.tsx | 18 +-
karavan-designer/src/designer/DslElement.tsx | 57 +-
karavan-designer/src/designer/DslPath.tsx | 2 +-
karavan-designer/src/designer/DslProperties.tsx | 58 +-
karavan-designer/src/designer/DslSelector.tsx | 4 +-
karavan-designer/src/designer/KaravanDesigner.tsx | 23 +-
.../src/designer/field/DataFormatField.tsx | 1 -
.../src/designer/field/DslPropertyField.tsx | 4 +-
.../camel/karavan/generator/CamelApiGenerator.java | 262 ++++
.../karavan/generator/CamelModelGenerator.java | 295 +---
.../karavan/generator/CamelYamlStepsGenerator.java | 161 ++
.../main/resources/CamelApi.addStep.choiceStep.tx | 18 +-
.../src/main/resources/CamelApi.camelize.tx | 29 -
.../src/main/resources/CamelApi.createChoice.tx | 10 +-
.../main/resources/CamelApi.findStep.choiceStep.tx | 8 +-
.../src/main/resources/CamelApi.findStep.footer.tx | 4 +-
.../src/main/resources/CamelApi.findStep.header.tx | 4 +-
.../{camel-model.template => CamelModel.ts} | 11 +-
.../src/main/resources/CamelYamlStep.readChoice.tx | 9 +
.../main/resources/CamelYamlStep.readOtherwise.tx | 6 +
.../src/main/resources/CamelYamlStep.readWhen.tx | 7 +
43 files changed, 2606 insertions(+), 1934 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 16ecc8d..0aaf4e2 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -47,11 +47,11 @@ jobs:
# Building Karavan VSCode extensions
- name: Karavan VS Code extension (install dependencies)
working-directory: ./karavan-vscode
- run: yarn install
+ run: npm install
- name: Karavan VS Code extension (build)
working-directory: ./karavan-vscode
- run: yarn run package
+ run: npm run package
- name: Karavan VS Code extension (install vsce)
working-directory: ./karavan-vscode
diff --git a/karavan-core/src/core/api/CamelApi.ts b/karavan-core/src/core/api/CamelApi.ts
index 2b31b00..28bff63 100644
--- a/karavan-core/src/core/api/CamelApi.ts
+++ b/karavan-core/src/core/api/CamelApi.ts
@@ -3,111 +3,80 @@
*/
import {
CamelElement,
- ProcessorStep,
- ProcessorStepMeta,
- FromStep,
+ CamelElementMeta,
+ From,
Expression,
- PolicyStep,
- SetPropertyStep,
- SagaStep,
- ToDStep,
- ThreadsStep,
- InterceptSendToEndpointStep,
- LogStep,
- LoopStep,
- DelayStep,
- SampleStep,
- DoFinallyStep,
- LoadBalanceStep,
- ValidateStep,
- TransformStep,
- RemoveHeadersStep,
- IdempotentConsumerStep,
- InterceptStep,
+ Policy,
+ SetProperty,
+ Saga,
+ ToD,
+ Threads,
+ InterceptSendToEndpoint,
+ Log,
+ Loop,
+ Delay,
+ Sample,
+ DoFinally,
+ LoadBalance,
+ Validate,
+ Transform,
+ RemoveHeaders,
+ IdempotentConsumer,
+ Intercept,
When,
- ProcessStep,
- OnFallbackStep,
- MarshalStep,
- OnCompletionStep,
- ClaimCheckStep,
- DoCatchStep,
- InOnlyStep,
- ConvertBodyToStep,
- CircuitBreakerStep,
- PollEnrichStep,
+ Process,
+ OnFallback,
+ Marshal,
+ OnCompletion,
+ ClaimCheck,
+ DoCatch,
+ InOnly,
+ ConvertBodyTo,
+ CircuitBreaker,
+ PollEnrich,
Otherwise,
- ResequenceStep,
- RoutingSlipStep,
- BeanStep,
- RecipientListStep,
- KameletStep,
- DynamicRouterStep,
- RollbackStep,
- InOutStep,
- EnrichStep,
- SplitStep,
- WireTapStep,
- MulticastStep,
- StopStep,
- SetBodyStep,
- SortStep,
- InterceptFromStep,
- ThrowExceptionStep,
- ToStep,
- FilterStep,
- ServiceCallStep,
- ThrottleStep,
- WhenSkipSendToEndpointStep,
- RemovePropertiesStep,
- SetHeaderStep,
- ChoiceStep,
- AggregateStep,
- RemovePropertyStep,
- RemoveHeaderStep,
- ScriptStep,
- DoTryStep,
- SetExchangePatternStep,
- TransactedStep,
- PipelineStep,
- UnmarshalStep,
+ Resequence,
+ RoutingSlip,
+ Bean,
+ RecipientList,
+ Kamelet,
+ DynamicRouter,
+ Rollback,
+ InOut,
+ Enrich,
+ Split,
+ WireTap,
+ Multicast,
+ Stop,
+ SetBody,
+ Sort,
+ InterceptFrom,
+ ThrowException,
+ To,
+ Filter,
+ ServiceCall,
+ Throttle,
+ WhenSkipSendToEndpoint,
+ RemoveProperties,
+ SetHeader,
+ Choice,
+ Aggregate,
+ RemoveProperty,
+ RemoveHeader,
+ Script,
+ DoTry,
+ SetExchangePattern,
+ Transacted,
+ Pipeline,
+ Unmarshal,
} from '../model/CamelModel'
-
import * as dataFormat from '../model/CamelDataFormat';
+import {CamelUtil} from "./CamelUtil";
export class CamelApi {
- static capitalizeName = (name: string) => {
- try {
- return name[0].toUpperCase() + name.substring(1);
- } catch (e) {
- return name;
- }
- };
-
- static camelizeName = (
- name: string,
- separator: string,
- firstSmall: boolean
- ) => {
- const res = name
- .split(separator)
- .map((value) => CamelApi.capitalizeName(value))
- .join("");
- return firstSmall ? res[0].toLowerCase() + res.substring(1) : res;
- };
-
- static camelizeBody = (name: string, body: any, clone: boolean): any => {
- if (body){
- const oldKey = Object.keys(body)[0];
- const key = CamelApi.camelizeName(oldKey, '-', true);
- return !clone && key === name ? {[key]: body[oldKey]} : body;
- } else {
- return {};
- }
- };
-
static createStep = (name: string, body: any, clone: boolean = false): CamelElement => {
- const newBody = CamelApi.camelizeBody(name, body, clone);
+ const newBody = CamelUtil.camelizeBody(name, body, clone);
switch (name){
case 'from': return CamelApi.createFrom(newBody);
case 'expression': return CamelApi.createExpression(newBody);
@@ -174,174 +143,174 @@ export class CamelApi {
case 'transacted': return CamelApi.createTransacted(newBody);
case 'pipeline': return CamelApi.createPipeline(newBody);
case 'unmarshal': return CamelApi.createUnmarshal(newBody);
- default: return new ProcessorStep('');
+ default: return new CamelElement('');
}
}
static createExpression = (element: any): Expression => {
return new Expression({...element})
}
- static createFrom = (element: any): FromStep => {
- if (element && element.from && typeof element.from === 'string') element.from = {uri: element.from};
- const fromStep = element ? new FromStep({...element.from}) : new FromStep();
- fromStep.from.steps = CamelApi.createSteps(element?.from?.steps);
- fromStep.uuid = element?.uuid ? element.uuid : fromStep.uuid;
- return fromStep;
+ static createFrom = (element: any): From => {
+ if (element && typeof element === 'string') element = {uri: element};
+ const from = element ? new From({...element}) : new From();
+ from.steps = CamelApi.createSteps(element?.steps);
+ from.uuid = element?.uuid ? element.uuid : from.uuid;
+ return from;
}
- static createPolicy = (element: any): PolicyStep => {
- const policyStep = element ? new PolicyStep({...element.policy}) : new PolicyStep();
- policyStep.policy.steps = CamelApi.createSteps(element?.policy?.steps);
- policyStep.uuid = element?.uuid ? element.uuid : policyStep.uuid;
- return policyStep;
+ static createPolicy = (element: any): Policy => {
+ const policy = element ? new Policy({...element}) : new Policy();
+ policy.steps = CamelApi.createSteps(element?.steps);
+ policy.uuid = element?.uuid ? element.uuid : policy.uuid;
+ return policy;
}
- static createSetProperty = (element: any): SetPropertyStep => {
- const setPropertyStep = element ? new SetPropertyStep({...element.setProperty}) : new SetPropertyStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.setProperty);
+ static createSetProperty = (element: any): SetProperty => {
+ const setProperty = element ? new SetProperty({...element}) : new SetProperty();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- setPropertyStep.setProperty.expression = new Expression({[implicitExpression]: element.setProperty[implicitExpression]});
- delete (setPropertyStep.setProperty as any)[implicitExpression];
+ setProperty.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (setProperty as any)[implicitExpression];
} else {
- setPropertyStep.setProperty.expression = CamelApi.createExpression(element?.setProperty?.expression);
+ setProperty.expression = CamelApi.createExpression(element?.expression);
}
- setPropertyStep.uuid = element?.uuid ? element.uuid : setPropertyStep.uuid;
- return setPropertyStep;
+ setProperty.uuid = element?.uuid ? element.uuid : setProperty.uuid;
+ return setProperty;
}
- static createSaga = (element: any): SagaStep => {
- const sagaStep = element ? new SagaStep({...element.saga}) : new SagaStep();
- sagaStep.saga.steps = CamelApi.createSteps(element?.saga?.steps);
- sagaStep.uuid = element?.uuid ? element.uuid : sagaStep.uuid;
- return sagaStep;
+ static createSaga = (element: any): Saga => {
+ const saga = element ? new Saga({...element}) : new Saga();
+ saga.steps = CamelApi.createSteps(element?.steps);
+ saga.uuid = element?.uuid ? element.uuid : saga.uuid;
+ return saga;
}
- static createToD = (element: any): ToDStep => {
- if (element && element.toD && typeof element.toD === 'string') element.toD = {uri: element.toD};
- const toDStep = element ? new ToDStep({...element.toD}) : new ToDStep();
- toDStep.uuid = element?.uuid ? element.uuid : toDStep.uuid;
- return toDStep;
+ static createToD = (element: any): ToD => {
+ if (element && typeof element === 'string') element = {uri: element};
+ const toD = element ? new ToD({...element}) : new ToD();
+ toD.uuid = element?.uuid ? element.uuid : toD.uuid;
+ return toD;
}
- static createThreads = (element: any): ThreadsStep => {
- const threadsStep = element ? new ThreadsStep({...element.threads}) : new ThreadsStep();
- threadsStep.uuid = element?.uuid ? element.uuid : threadsStep.uuid;
- return threadsStep;
+ static createThreads = (element: any): Threads => {
+ const threads = element ? new Threads({...element}) : new Threads();
+ threads.uuid = element?.uuid ? element.uuid : threads.uuid;
+ return threads;
}
- static createInterceptSendToEndpoint = (element: any): InterceptSendToEndpointStep => {
- if (element && element.interceptSendToEndpoint && typeof element.interceptSendToEndpoint === 'string') element.interceptSendToEndpoint = {uri: element.interceptSendToEndpoint};
- const interceptSendToEndpointStep = element ? new InterceptSendToEndpointStep({...element.interceptSendToEndpoint}) : new InterceptSendToEndpointStep();
- interceptSendToEndpointStep.interceptSendToEndpoint.steps = CamelApi.createSteps(element?.interceptSendToEndpoint?.steps);
- interceptSendToEndpointStep.uuid = element?.uuid ? element.uuid : interceptSendToEndpointStep.uuid;
- return interceptSendToEndpointStep;
+ static createInterceptSendToEndpoint = (element: any): InterceptSendToEndpoint => {
+ if (element && typeof element === 'string') element = {uri: element};
+ const interceptSendToEndpoint = element ? new InterceptSendToEndpoint({...element}) : new InterceptSendToEndpoint();
+ interceptSendToEndpoint.steps = CamelApi.createSteps(element?.steps);
+ interceptSendToEndpoint.uuid = element?.uuid ? element.uuid : interceptSendToEndpoint.uuid;
+ return interceptSendToEndpoint;
}
- static createLog = (element: any): LogStep => {
- if (element && element.log && typeof element.log === 'string') element.log = {message: element.log};
- const logStep = element ? new LogStep({...element.log}) : new LogStep();
- logStep.uuid = element?.uuid ? element.uuid : logStep.uuid;
- return logStep;
+ static createLog = (element: any): Log => {
+ if (element && typeof element === 'string') element = {message: element};
+ const log = element ? new Log({...element}) : new Log();
+ log.uuid = element?.uuid ? element.uuid : log.uuid;
+ return log;
}
- static createLoop = (element: any): LoopStep => {
- const loopStep = element ? new LoopStep({...element.loop}) : new LoopStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.loop);
+ static createLoop = (element: any): Loop => {
+ const loop = element ? new Loop({...element}) : new Loop();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- loopStep.loop.expression = new Expression({[implicitExpression]: element.loop[implicitExpression]});
- delete (loopStep.loop as any)[implicitExpression];
+ loop.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (loop as any)[implicitExpression];
} else {
- loopStep.loop.expression = CamelApi.createExpression(element?.loop?.expression);
+ loop.expression = CamelApi.createExpression(element?.expression);
}
- loopStep.loop.steps = CamelApi.createSteps(element?.loop?.steps);
- loopStep.uuid = element?.uuid ? element.uuid : loopStep.uuid;
- return loopStep;
+ loop.steps = CamelApi.createSteps(element?.steps);
+ loop.uuid = element?.uuid ? element.uuid : loop.uuid;
+ return loop;
}
- static createDelay = (element: any): DelayStep => {
- const delayStep = element ? new DelayStep({...element.delay}) : new DelayStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.delay);
+ static createDelay = (element: any): Delay => {
+ const delay = element ? new Delay({...element}) : new Delay();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- delayStep.delay.expression = new Expression({[implicitExpression]: element.delay[implicitExpression]});
- delete (delayStep.delay as any)[implicitExpression];
+ delay.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (delay as any)[implicitExpression];
} else {
- delayStep.delay.expression = CamelApi.createExpression(element?.delay?.expression);
+ delay.expression = CamelApi.createExpression(element?.expression);
}
- delayStep.uuid = element?.uuid ? element.uuid : delayStep.uuid;
- return delayStep;
+ delay.uuid = element?.uuid ? element.uuid : delay.uuid;
+ return delay;
}
- static createSample = (element: any): SampleStep => {
- const sampleStep = element ? new SampleStep({...element.sample}) : new SampleStep();
- sampleStep.uuid = element?.uuid ? element.uuid : sampleStep.uuid;
- return sampleStep;
+ static createSample = (element: any): Sample => {
+ const sample = element ? new Sample({...element}) : new Sample();
+ sample.uuid = element?.uuid ? element.uuid : sample.uuid;
+ return sample;
}
- static createDoFinally = (element: any): DoFinallyStep => {
- const doFinallyStep = element ? new DoFinallyStep({...element.doFinally}) : new DoFinallyStep();
- doFinallyStep.doFinally.steps = CamelApi.createSteps(element?.doFinally?.steps);
- doFinallyStep.uuid = element?.uuid ? element.uuid : doFinallyStep.uuid;
- return doFinallyStep;
+ static createDoFinally = (element: any): DoFinally => {
+ const doFinally = element ? new DoFinally({...element}) : new DoFinally();
+ doFinally.steps = CamelApi.createSteps(element?.steps);
+ doFinally.uuid = element?.uuid ? element.uuid : doFinally.uuid;
+ return doFinally;
}
- static createLoadBalance = (element: any): LoadBalanceStep => {
- const loadBalanceStep = element ? new LoadBalanceStep({...element.loadBalance}) : new LoadBalanceStep();
- loadBalanceStep.loadBalance.steps = CamelApi.createSteps(element?.loadBalance?.steps);
- loadBalanceStep.uuid = element?.uuid ? element.uuid : loadBalanceStep.uuid;
- return loadBalanceStep;
+ static createLoadBalance = (element: any): LoadBalance => {
+ const loadBalance = element ? new LoadBalance({...element}) : new LoadBalance();
+ loadBalance.steps = CamelApi.createSteps(element?.steps);
+ loadBalance.uuid = element?.uuid ? element.uuid : loadBalance.uuid;
+ return loadBalance;
}
- static createValidate = (element: any): ValidateStep => {
- const validateStep = element ? new ValidateStep({...element.validate}) : new ValidateStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.validate);
+ static createValidate = (element: any): Validate => {
+ const validate = element ? new Validate({...element}) : new Validate();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- validateStep.validate.expression = new Expression({[implicitExpression]: element.validate[implicitExpression]});
- delete (validateStep.validate as any)[implicitExpression];
+ validate.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (validate as any)[implicitExpression];
} else {
- validateStep.validate.expression = CamelApi.createExpression(element?.validate?.expression);
+ validate.expression = CamelApi.createExpression(element?.expression);
}
- validateStep.uuid = element?.uuid ? element.uuid : validateStep.uuid;
- return validateStep;
+ validate.uuid = element?.uuid ? element.uuid : validate.uuid;
+ return validate;
}
- static createTransform = (element: any): TransformStep => {
- const transformStep = element ? new TransformStep({...element.transform}) : new TransformStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.transform);
+ static createTransform = (element: any): Transform => {
+ const transform = element ? new Transform({...element}) : new Transform();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- transformStep.transform.expression = new Expression({[implicitExpression]: element.transform[implicitExpression]});
- delete (transformStep.transform as any)[implicitExpression];
+ transform.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (transform as any)[implicitExpression];
} else {
- transformStep.transform.expression = CamelApi.createExpression(element?.transform?.expression);
+ transform.expression = CamelApi.createExpression(element?.expression);
}
- transformStep.uuid = element?.uuid ? element.uuid : transformStep.uuid;
- return transformStep;
+ transform.uuid = element?.uuid ? element.uuid : transform.uuid;
+ return transform;
}
- static createRemoveHeaders = (element: any): RemoveHeadersStep => {
- if (element && element.removeHeaders && typeof element.removeHeaders === 'string') element.removeHeaders = {pattern: element.removeHeaders};
- const removeHeadersStep = element ? new RemoveHeadersStep({...element.removeHeaders}) : new RemoveHeadersStep();
- removeHeadersStep.uuid = element?.uuid ? element.uuid : removeHeadersStep.uuid;
- return removeHeadersStep;
+ static createRemoveHeaders = (element: any): RemoveHeaders => {
+ if (element && typeof element === 'string') element = {pattern: element};
+ const removeHeaders = element ? new RemoveHeaders({...element}) : new RemoveHeaders();
+ removeHeaders.uuid = element?.uuid ? element.uuid : removeHeaders.uuid;
+ return removeHeaders;
}
- static createIdempotentConsumer = (element: any): IdempotentConsumerStep => {
- const idempotentConsumerStep = element ? new IdempotentConsumerStep({...element.idempotentConsumer}) : new IdempotentConsumerStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.idempotentConsumer);
+ static createIdempotentConsumer = (element: any): IdempotentConsumer => {
+ const idempotentConsumer = element ? new IdempotentConsumer({...element}) : new IdempotentConsumer();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- idempotentConsumerStep.idempotentConsumer.expression = new Expression({[implicitExpression]: element.idempotentConsumer[implicitExpression]});
- delete (idempotentConsumerStep.idempotentConsumer as any)[implicitExpression];
+ idempotentConsumer.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (idempotentConsumer as any)[implicitExpression];
} else {
- idempotentConsumerStep.idempotentConsumer.expression = CamelApi.createExpression(element?.idempotentConsumer?.expression);
+ idempotentConsumer.expression = CamelApi.createExpression(element?.expression);
}
- idempotentConsumerStep.idempotentConsumer.steps = CamelApi.createSteps(element?.idempotentConsumer?.steps);
- idempotentConsumerStep.uuid = element?.uuid ? element.uuid : idempotentConsumerStep.uuid;
- return idempotentConsumerStep;
+ idempotentConsumer.steps = CamelApi.createSteps(element?.steps);
+ idempotentConsumer.uuid = element?.uuid ? element.uuid : idempotentConsumer.uuid;
+ return idempotentConsumer;
}
- static createIntercept = (element: any): InterceptStep => {
- const interceptStep = element ? new InterceptStep({...element.intercept}) : new InterceptStep();
- interceptStep.intercept.steps = CamelApi.createSteps(element?.intercept?.steps);
- interceptStep.uuid = element?.uuid ? element.uuid : interceptStep.uuid;
- return interceptStep;
+ static createIntercept = (element: any): Intercept => {
+ const intercept = element ? new Intercept({...element}) : new Intercept();
+ intercept.steps = CamelApi.createSteps(element?.steps);
+ intercept.uuid = element?.uuid ? element.uuid : intercept.uuid;
+ return intercept;
}
static createWhen = (element: any): When => {
@@ -352,121 +321,121 @@ export class CamelApi {
return when
}
- static createProcess = (element: any): ProcessStep => {
- const processStep = element ? new ProcessStep({...element.process}) : new ProcessStep();
- processStep.uuid = element?.uuid ? element.uuid : processStep.uuid;
- return processStep;
- }
-
- static createOnFallback = (element: any): OnFallbackStep => {
- const onFallbackStep = element ? new OnFallbackStep({...element.onFallback}) : new OnFallbackStep();
- onFallbackStep.onFallback.steps = CamelApi.createSteps(element?.onFallback?.steps);
- onFallbackStep.uuid = element?.uuid ? element.uuid : onFallbackStep.uuid;
- return onFallbackStep;
- }
-
- static createMarshal = (element: any): MarshalStep => {
- const marshalStep = element ? new MarshalStep({...element.marshal}) : new MarshalStep();
- if (element.marshal?.any23 !== undefined) marshalStep.marshal.any23 = new dataFormat.Any23DataFormat(element.marshal.any23);
- if (element.marshal?.asn1 !== undefined) marshalStep.marshal.asn1 = new dataFormat.ASN1DataFormat(element.marshal.asn1);
- if (element.marshal?.avro !== undefined) marshalStep.marshal.avro = new dataFormat.AvroDataFormat(element.marshal.avro);
- if (element.marshal?.barcode !== undefined) marshalStep.marshal.barcode = new dataFormat.BarcodeDataFormat(element.marshal.barcode);
- if (element.marshal?.base64 !== undefined) marshalStep.marshal.base64 = new dataFormat.Base64DataFormat(element.marshal.base64);
- if (element.marshal?.beanio !== undefined) marshalStep.marshal.beanio = new dataFormat.BeanioDataFormat(element.marshal.beanio);
- if (element.marshal?.bindy !== undefined) marshalStep.marshal.bindy = new dataFormat.BindyDataFormat(element.marshal.bindy);
- if (element.marshal?.cbor !== undefined) marshalStep.marshal.cbor = new dataFormat.CBORDataFormat(element.marshal.cbor);
- if (element.marshal?.crypto !== undefined) marshalStep.marshal.crypto = new dataFormat.CryptoDataFormat(element.marshal.crypto);
- if (element.marshal?.csv !== undefined) marshalStep.marshal.csv = new dataFormat.CsvDataFormat(element.marshal.csv);
- if (element.marshal?.custom !== undefined) marshalStep.marshal.custom = new dataFormat.CustomDataFormat(element.marshal.custom);
- if (element.marshal?.fhirJson !== undefined) marshalStep.marshal.fhirJson = new dataFormat.FhirJsonDataFormat(element.marshal.fhirJson);
- if (element.marshal?.fhirXml !== undefined) marshalStep.marshal.fhirXml = new dataFormat.FhirXmlDataFormat(element.marshal.fhirXml);
- if (element.marshal?.flatpack !== undefined) marshalStep.marshal.flatpack = new dataFormat.FlatpackDataFormat(element.marshal.flatpack);
- if (element.marshal?.grok !== undefined) marshalStep.marshal.grok = new dataFormat.GrokDataFormat(element.marshal.grok);
- if (element.marshal?.gzip !== undefined) marshalStep.marshal.gzip = new dataFormat.GzipDataFormat(element.marshal.gzip);
- if (element.marshal?.hl7 !== undefined) marshalStep.marshal.hl7 = new dataFormat.HL7DataFormat(element.marshal.hl7);
- if (element.marshal?.ical !== undefined) marshalStep.marshal.ical = new dataFormat.IcalDataFormat(element.marshal.ical);
- if (element.marshal?.jacksonxml !== undefined) marshalStep.marshal.jacksonxml = new dataFormat.JacksonXMLDataFormat(element.marshal.jacksonxml);
- if (element.marshal?.jaxb !== undefined) marshalStep.marshal.jaxb = new dataFormat.JaxbDataFormat(element.marshal.jaxb);
- if (element.marshal?.json !== undefined) marshalStep.marshal.json = new dataFormat.JsonDataFormat(element.marshal.json);
- if (element.marshal?.jsonApi !== undefined) marshalStep.marshal.jsonApi = new dataFormat.JsonApiDataFormat(element.marshal.jsonApi);
- if (element.marshal?.lzf !== undefined) marshalStep.marshal.lzf = new dataFormat.LZFDataFormat(element.marshal.lzf);
- if (element.marshal?.mimeMultipart !== undefined) marshalStep.marshal.mimeMultipart = new dataFormat.MimeMultipartDataFormat(element.marshal.mimeMultipart);
- if (element.marshal?.pgp !== undefined) marshalStep.marshal.pgp = new dataFormat.PGPDataFormat(element.marshal.pgp);
- if (element.marshal?.protobuf !== undefined) marshalStep.marshal.protobuf = new dataFormat.ProtobufDataFormat(element.marshal.protobuf);
- if (element.marshal?.rss !== undefined) marshalStep.marshal.rss = new dataFormat.RssDataFormat(element.marshal.rss);
- if (element.marshal?.secureXml !== undefined) marshalStep.marshal.secureXml = new dataFormat.XMLSecurityDataFormat(element.marshal.secureXml);
- if (element.marshal?.soapjaxb !== undefined) marshalStep.marshal.soapjaxb = new dataFormat.SoapJaxbDataFormat(element.marshal.soapjaxb);
- if (element.marshal?.syslog !== undefined) marshalStep.marshal.syslog = new dataFormat.SyslogDataFormat(element.marshal.syslog);
- if (element.marshal?.tarfile !== undefined) marshalStep.marshal.tarfile = new dataFormat.TarFileDataFormat(element.marshal.tarfile);
- if (element.marshal?.thrift !== undefined) marshalStep.marshal.thrift = new dataFormat.ThriftDataFormat(element.marshal.thrift);
- if (element.marshal?.tidyMarkup !== undefined) marshalStep.marshal.tidyMarkup = new dataFormat.TidyMarkupDataFormat(element.marshal.tidyMarkup);
- if (element.marshal?.univocityCsv !== undefined) marshalStep.marshal.univocityCsv = new dataFormat.UniVocityCsvDataFormat(element.marshal.univocityCsv);
- if (element.marshal?.univocityFixed !== undefined) marshalStep.marshal.univocityFixed = new dataFormat.UniVocityFixedWidthDataFormat(element.marshal.univocityFixed);
- if (element.marshal?.univocityTsv !== undefined) marshalStep.marshal.univocityTsv = new dataFormat.UniVocityTsvDataFormat(element.marshal.univocityTsv);
- if (element.marshal?.xmlrpc !== undefined) marshalStep.marshal.xmlrpc = new dataFormat.XmlRpcDataFormat(element.marshal.xmlrpc);
- if (element.marshal?.xstream !== undefined) marshalStep.marshal.xstream = new dataFormat.XStreamDataFormat(element.marshal.xstream);
- if (element.marshal?.yaml !== undefined) marshalStep.marshal.yaml = new dataFormat.YAMLDataFormat(element.marshal.yaml);
- if (element.marshal?.zip !== undefined) marshalStep.marshal.zip = new dataFormat.ZipDeflaterDataFormat(element.marshal.zip);
- if (element.marshal?.zipfile !== undefined) marshalStep.marshal.zipfile = new dataFormat.ZipFileDataFormat(element.marshal.zipfile);
- marshalStep.uuid = element?.uuid ? element.uuid : marshalStep.uuid;
- return marshalStep;
- }
-
- static createOnCompletion = (element: any): OnCompletionStep => {
- const onCompletionStep = element ? new OnCompletionStep({...element.onCompletion}) : new OnCompletionStep();
- onCompletionStep.onCompletion.onWhen = CamelApi.createWhen(element?.onCompletion?.onWhen);
- onCompletionStep.onCompletion.steps = CamelApi.createSteps(element?.onCompletion?.steps);
- onCompletionStep.uuid = element?.uuid ? element.uuid : onCompletionStep.uuid;
- return onCompletionStep;
- }
-
- static createClaimCheck = (element: any): ClaimCheckStep => {
- const claimCheckStep = element ? new ClaimCheckStep({...element.claimCheck}) : new ClaimCheckStep();
- claimCheckStep.uuid = element?.uuid ? element.uuid : claimCheckStep.uuid;
- return claimCheckStep;
- }
-
- static createDoCatch = (element: any): DoCatchStep => {
- const doCatchStep = element ? new DoCatchStep({...element.doCatch}) : new DoCatchStep();
- doCatchStep.doCatch.onWhen = CamelApi.createWhen(element?.doCatch?.onWhen);
- doCatchStep.doCatch.steps = CamelApi.createSteps(element?.doCatch?.steps);
- doCatchStep.uuid = element?.uuid ? element.uuid : doCatchStep.uuid;
- return doCatchStep;
- }
-
- static createInOnly = (element: any): InOnlyStep => {
- if (element && element.inOnly && typeof element.inOnly === 'string') element.inOnly = {uri: element.inOnly};
- const inOnlyStep = element ? new InOnlyStep({...element.inOnly}) : new InOnlyStep();
- inOnlyStep.uuid = element?.uuid ? element.uuid : inOnlyStep.uuid;
- return inOnlyStep;
- }
-
- static createConvertBodyTo = (element: any): ConvertBodyToStep => {
- if (element && element.convertBodyTo && typeof element.convertBodyTo === 'string') element.convertBodyTo = {type: element.convertBodyTo};
- const convertBodyToStep = element ? new ConvertBodyToStep({...element.convertBodyTo}) : new ConvertBodyToStep();
- convertBodyToStep.uuid = element?.uuid ? element.uuid : convertBodyToStep.uuid;
- return convertBodyToStep;
- }
-
- static createCircuitBreaker = (element: any): CircuitBreakerStep => {
- const circuitBreakerStep = element ? new CircuitBreakerStep({...element.circuitBreaker}) : new CircuitBreakerStep();
- circuitBreakerStep.circuitBreaker.onFallback = CamelApi.createOnFallback(element?.circuitBreaker?.onFallback);
- circuitBreakerStep.circuitBreaker.steps = CamelApi.createSteps(element?.circuitBreaker?.steps);
- circuitBreakerStep.uuid = element?.uuid ? element.uuid : circuitBreakerStep.uuid;
- return circuitBreakerStep;
- }
-
- static createPollEnrich = (element: any): PollEnrichStep => {
- const pollEnrichStep = element ? new PollEnrichStep({...element.pollEnrich}) : new PollEnrichStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.pollEnrich);
+ static createProcess = (element: any): Process => {
+ const process = element ? new Process({...element}) : new Process();
+ process.uuid = element?.uuid ? element.uuid : process.uuid;
+ return process;
+ }
+
+ static createOnFallback = (element: any): OnFallback => {
+ const onFallback = element ? new OnFallback({...element}) : new OnFallback();
+ onFallback.steps = CamelApi.createSteps(element?.steps);
+ onFallback.uuid = element?.uuid ? element.uuid : onFallback.uuid;
+ return onFallback;
+ }
+
+ static createMarshal = (element: any): Marshal => {
+ const marshal = element ? new Marshal({...element}) : new Marshal();
+ if (element.any23 !== undefined) marshal.any23 = new dataFormat.Any23DataFormat(element.any23);
+ if (element.asn1 !== undefined) marshal.asn1 = new dataFormat.ASN1DataFormat(element.asn1);
+ if (element.avro !== undefined) marshal.avro = new dataFormat.AvroDataFormat(element.avro);
+ if (element.barcode !== undefined) marshal.barcode = new dataFormat.BarcodeDataFormat(element.barcode);
+ if (element.base64 !== undefined) marshal.base64 = new dataFormat.Base64DataFormat(element.base64);
+ if (element.beanio !== undefined) marshal.beanio = new dataFormat.BeanioDataFormat(element.beanio);
+ if (element.bindy !== undefined) marshal.bindy = new dataFormat.BindyDataFormat(element.bindy);
+ if (element.cbor !== undefined) marshal.cbor = new dataFormat.CBORDataFormat(element.cbor);
+ if (element.crypto !== undefined) marshal.crypto = new dataFormat.CryptoDataFormat(element.crypto);
+ if (element.csv !== undefined) marshal.csv = new dataFormat.CsvDataFormat(element.csv);
+ if (element.custom !== undefined) marshal.custom = new dataFormat.CustomDataFormat(element.custom);
+ if (element.fhirJson !== undefined) marshal.fhirJson = new dataFormat.FhirJsonDataFormat(element.fhirJson);
+ if (element.fhirXml !== undefined) marshal.fhirXml = new dataFormat.FhirXmlDataFormat(element.fhirXml);
+ if (element.flatpack !== undefined) marshal.flatpack = new dataFormat.FlatpackDataFormat(element.flatpack);
+ if (element.grok !== undefined) marshal.grok = new dataFormat.GrokDataFormat(element.grok);
+ if (element.gzip !== undefined) marshal.gzip = new dataFormat.GzipDataFormat(element.gzip);
+ if (element.hl7 !== undefined) marshal.hl7 = new dataFormat.HL7DataFormat(element.hl7);
+ if (element.ical !== undefined) marshal.ical = new dataFormat.IcalDataFormat(element.ical);
+ if (element.jacksonxml !== undefined) marshal.jacksonxml = new dataFormat.JacksonXMLDataFormat(element.jacksonxml);
+ if (element.jaxb !== undefined) marshal.jaxb = new dataFormat.JaxbDataFormat(element.jaxb);
+ if (element.json !== undefined) marshal.json = new dataFormat.JsonDataFormat(element.json);
+ if (element.jsonApi !== undefined) marshal.jsonApi = new dataFormat.JsonApiDataFormat(element.jsonApi);
+ if (element.lzf !== undefined) marshal.lzf = new dataFormat.LZFDataFormat(element.lzf);
+ if (element.mimeMultipart !== undefined) marshal.mimeMultipart = new dataFormat.MimeMultipartDataFormat(element.mimeMultipart);
+ if (element.pgp !== undefined) marshal.pgp = new dataFormat.PGPDataFormat(element.pgp);
+ if (element.protobuf !== undefined) marshal.protobuf = new dataFormat.ProtobufDataFormat(element.protobuf);
+ if (element.rss !== undefined) marshal.rss = new dataFormat.RssDataFormat(element.rss);
+ if (element.secureXml !== undefined) marshal.secureXml = new dataFormat.XMLSecurityDataFormat(element.secureXml);
+ if (element.soapjaxb !== undefined) marshal.soapjaxb = new dataFormat.SoapJaxbDataFormat(element.soapjaxb);
+ if (element.syslog !== undefined) marshal.syslog = new dataFormat.SyslogDataFormat(element.syslog);
+ if (element.tarfile !== undefined) marshal.tarfile = new dataFormat.TarFileDataFormat(element.tarfile);
+ if (element.thrift !== undefined) marshal.thrift = new dataFormat.ThriftDataFormat(element.thrift);
+ if (element.tidyMarkup !== undefined) marshal.tidyMarkup = new dataFormat.TidyMarkupDataFormat(element.tidyMarkup);
+ if (element.univocityCsv !== undefined) marshal.univocityCsv = new dataFormat.UniVocityCsvDataFormat(element.univocityCsv);
+ if (element.univocityFixed !== undefined) marshal.univocityFixed = new dataFormat.UniVocityFixedWidthDataFormat(element.univocityFixed);
+ if (element.univocityTsv !== undefined) marshal.univocityTsv = new dataFormat.UniVocityTsvDataFormat(element.univocityTsv);
+ if (element.xmlrpc !== undefined) marshal.xmlrpc = new dataFormat.XmlRpcDataFormat(element.xmlrpc);
+ if (element.xstream !== undefined) marshal.xstream = new dataFormat.XStreamDataFormat(element.xstream);
+ if (element.yaml !== undefined) marshal.yaml = new dataFormat.YAMLDataFormat(element.yaml);
+ if (element.zip !== undefined) marshal.zip = new dataFormat.ZipDeflaterDataFormat(element.zip);
+ if (element.zipfile !== undefined) marshal.zipfile = new dataFormat.ZipFileDataFormat(element.zipfile);
+ marshal.uuid = element?.uuid ? element.uuid : marshal.uuid;
+ return marshal;
+ }
+
+ static createOnCompletion = (element: any): OnCompletion => {
+ const onCompletion = element ? new OnCompletion({...element}) : new OnCompletion();
+ onCompletion.onWhen = CamelApi.createWhen(element?.onCompletion?.onWhen);
+ onCompletion.steps = CamelApi.createSteps(element?.steps);
+ onCompletion.uuid = element?.uuid ? element.uuid : onCompletion.uuid;
+ return onCompletion;
+ }
+
+ static createClaimCheck = (element: any): ClaimCheck => {
+ const claimCheck = element ? new ClaimCheck({...element}) : new ClaimCheck();
+ claimCheck.uuid = element?.uuid ? element.uuid : claimCheck.uuid;
+ return claimCheck;
+ }
+
+ static createDoCatch = (element: any): DoCatch => {
+ const doCatch = element ? new DoCatch({...element}) : new DoCatch();
+ doCatch.onWhen = CamelApi.createWhen(element?.doCatch?.onWhen);
+ doCatch.steps = CamelApi.createSteps(element?.steps);
+ doCatch.uuid = element?.uuid ? element.uuid : doCatch.uuid;
+ return doCatch;
+ }
+
+ static createInOnly = (element: any): InOnly => {
+ if (element && typeof element === 'string') element = {uri: element};
+ const inOnly = element ? new InOnly({...element}) : new InOnly();
+ inOnly.uuid = element?.uuid ? element.uuid : inOnly.uuid;
+ return inOnly;
+ }
+
+ static createConvertBodyTo = (element: any): ConvertBodyTo => {
+ if (element && typeof element === 'string') element = {type: element};
+ const convertBodyTo = element ? new ConvertBodyTo({...element}) : new ConvertBodyTo();
+ convertBodyTo.uuid = element?.uuid ? element.uuid : convertBodyTo.uuid;
+ return convertBodyTo;
+ }
+
+ static createCircuitBreaker = (element: any): CircuitBreaker => {
+ const circuitBreaker = element ? new CircuitBreaker({...element}) : new CircuitBreaker();
+ circuitBreaker.onFallback = CamelApi.createOnFallback(element?.circuitBreaker?.onFallback);
+ circuitBreaker.steps = CamelApi.createSteps(element?.steps);
+ circuitBreaker.uuid = element?.uuid ? element.uuid : circuitBreaker.uuid;
+ return circuitBreaker;
+ }
+
+ static createPollEnrich = (element: any): PollEnrich => {
+ const pollEnrich = element ? new PollEnrich({...element}) : new PollEnrich();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- pollEnrichStep.pollEnrich.expression = new Expression({[implicitExpression]: element.pollEnrich[implicitExpression]});
- delete (pollEnrichStep.pollEnrich as any)[implicitExpression];
+ pollEnrich.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (pollEnrich as any)[implicitExpression];
} else {
- pollEnrichStep.pollEnrich.expression = CamelApi.createExpression(element?.pollEnrich?.expression);
+ pollEnrich.expression = CamelApi.createExpression(element?.expression);
}
- pollEnrichStep.uuid = element?.uuid ? element.uuid : pollEnrichStep.uuid;
- return pollEnrichStep;
+ pollEnrich.uuid = element?.uuid ? element.uuid : pollEnrich.uuid;
+ return pollEnrich;
}
static createOtherwise = (element: any): Otherwise => {
@@ -476,480 +445,409 @@ export class CamelApi {
return otherwise
}
- static createResequence = (element: any): ResequenceStep => {
- const resequenceStep = element ? new ResequenceStep({...element.resequence}) : new ResequenceStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.resequence);
+ static createResequence = (element: any): Resequence => {
+ const resequence = element ? new Resequence({...element}) : new Resequence();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- resequenceStep.resequence.expression = new Expression({[implicitExpression]: element.resequence[implicitExpression]});
- delete (resequenceStep.resequence as any)[implicitExpression];
+ resequence.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (resequence as any)[implicitExpression];
} else {
- resequenceStep.resequence.expression = CamelApi.createExpression(element?.resequence?.expression);
+ resequence.expression = CamelApi.createExpression(element?.expression);
}
- resequenceStep.resequence.steps = CamelApi.createSteps(element?.resequence?.steps);
- resequenceStep.uuid = element?.uuid ? element.uuid : resequenceStep.uuid;
- return resequenceStep;
+ resequence.steps = CamelApi.createSteps(element?.steps);
+ resequence.uuid = element?.uuid ? element.uuid : resequence.uuid;
+ return resequence;
}
- static createRoutingSlip = (element: any): RoutingSlipStep => {
- const routingSlipStep = element ? new RoutingSlipStep({...element.routingSlip}) : new RoutingSlipStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.routingSlip);
+ static createRoutingSlip = (element: any): RoutingSlip => {
+ const routingSlip = element ? new RoutingSlip({...element}) : new RoutingSlip();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- routingSlipStep.routingSlip.expression = new Expression({[implicitExpression]: element.routingSlip[implicitExpression]});
- delete (routingSlipStep.routingSlip as any)[implicitExpression];
+ routingSlip.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (routingSlip as any)[implicitExpression];
} else {
- routingSlipStep.routingSlip.expression = CamelApi.createExpression(element?.routingSlip?.expression);
+ routingSlip.expression = CamelApi.createExpression(element?.expression);
}
- routingSlipStep.uuid = element?.uuid ? element.uuid : routingSlipStep.uuid;
- return routingSlipStep;
+ routingSlip.uuid = element?.uuid ? element.uuid : routingSlip.uuid;
+ return routingSlip;
}
- static createBean = (element: any): BeanStep => {
- const beanStep = element ? new BeanStep({...element.bean}) : new BeanStep();
- beanStep.uuid = element?.uuid ? element.uuid : beanStep.uuid;
- return beanStep;
+ static createBean = (element: any): Bean => {
+ const bean = element ? new Bean({...element}) : new Bean();
+ bean.uuid = element?.uuid ? element.uuid : bean.uuid;
+ return bean;
}
- static createRecipientList = (element: any): RecipientListStep => {
- const recipientListStep = element ? new RecipientListStep({...element.recipientList}) : new RecipientListStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.recipientList);
+ static createRecipientList = (element: any): RecipientList => {
+ const recipientList = element ? new RecipientList({...element}) : new RecipientList();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- recipientListStep.recipientList.expression = new Expression({[implicitExpression]: element.recipientList[implicitExpression]});
- delete (recipientListStep.recipientList as any)[implicitExpression];
+ recipientList.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (recipientList as any)[implicitExpression];
} else {
- recipientListStep.recipientList.expression = CamelApi.createExpression(element?.recipientList?.expression);
+ recipientList.expression = CamelApi.createExpression(element?.expression);
}
- recipientListStep.uuid = element?.uuid ? element.uuid : recipientListStep.uuid;
- return recipientListStep;
+ recipientList.uuid = element?.uuid ? element.uuid : recipientList.uuid;
+ return recipientList;
}
- static createKamelet = (element: any): KameletStep => {
- if (element && element.kamelet && typeof element.kamelet === 'string') element.kamelet = {name: element.kamelet};
- const kameletStep = element ? new KameletStep({...element.kamelet}) : new KameletStep();
- kameletStep.uuid = element?.uuid ? element.uuid : kameletStep.uuid;
- return kameletStep;
+ static createKamelet = (element: any): Kamelet => {
+ if (element && typeof element === 'string') element = {name: element};
+ const kamelet = element ? new Kamelet({...element}) : new Kamelet();
+ kamelet.uuid = element?.uuid ? element.uuid : kamelet.uuid;
+ return kamelet;
}
- static createDynamicRouter = (element: any): DynamicRouterStep => {
- const dynamicRouterStep = element ? new DynamicRouterStep({...element.dynamicRouter}) : new DynamicRouterStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.dynamicRouter);
+ static createDynamicRouter = (element: any): DynamicRouter => {
+ const dynamicRouter = element ? new DynamicRouter({...element}) : new DynamicRouter();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- dynamicRouterStep.dynamicRouter.expression = new Expression({[implicitExpression]: element.dynamicRouter[implicitExpression]});
- delete (dynamicRouterStep.dynamicRouter as any)[implicitExpression];
+ dynamicRouter.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (dynamicRouter as any)[implicitExpression];
} else {
- dynamicRouterStep.dynamicRouter.expression = CamelApi.createExpression(element?.dynamicRouter?.expression);
+ dynamicRouter.expression = CamelApi.createExpression(element?.expression);
}
- dynamicRouterStep.uuid = element?.uuid ? element.uuid : dynamicRouterStep.uuid;
- return dynamicRouterStep;
+ dynamicRouter.uuid = element?.uuid ? element.uuid : dynamicRouter.uuid;
+ return dynamicRouter;
}
- static createRollback = (element: any): RollbackStep => {
- const rollbackStep = element ? new RollbackStep({...element.rollback}) : new RollbackStep();
- rollbackStep.uuid = element?.uuid ? element.uuid : rollbackStep.uuid;
- return rollbackStep;
+ static createRollback = (element: any): Rollback => {
+ const rollback = element ? new Rollback({...element}) : new Rollback();
+ rollback.uuid = element?.uuid ? element.uuid : rollback.uuid;
+ return rollback;
}
- static createInOut = (element: any): InOutStep => {
- if (element && element.inOut && typeof element.inOut === 'string') element.inOut = {uri: element.inOut};
- const inOutStep = element ? new InOutStep({...element.inOut}) : new InOutStep();
- inOutStep.uuid = element?.uuid ? element.uuid : inOutStep.uuid;
- return inOutStep;
+ static createInOut = (element: any): InOut => {
+ if (element && typeof element === 'string') element = {uri: element};
+ const inOut = element ? new InOut({...element}) : new InOut();
+ inOut.uuid = element?.uuid ? element.uuid : inOut.uuid;
+ return inOut;
}
- static createEnrich = (element: any): EnrichStep => {
- const enrichStep = element ? new EnrichStep({...element.enrich}) : new EnrichStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.enrich);
+ static createEnrich = (element: any): Enrich => {
+ const enrich = element ? new Enrich({...element}) : new Enrich();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- enrichStep.enrich.expression = new Expression({[implicitExpression]: element.enrich[implicitExpression]});
- delete (enrichStep.enrich as any)[implicitExpression];
+ enrich.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (enrich as any)[implicitExpression];
} else {
- enrichStep.enrich.expression = CamelApi.createExpression(element?.enrich?.expression);
+ enrich.expression = CamelApi.createExpression(element?.expression);
}
- enrichStep.uuid = element?.uuid ? element.uuid : enrichStep.uuid;
- return enrichStep;
+ enrich.uuid = element?.uuid ? element.uuid : enrich.uuid;
+ return enrich;
}
- static createSplit = (element: any): SplitStep => {
- const splitStep = element ? new SplitStep({...element.split}) : new SplitStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.split);
+ static createSplit = (element: any): Split => {
+ const split = element ? new Split({...element}) : new Split();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- splitStep.split.expression = new Expression({[implicitExpression]: element.split[implicitExpression]});
- delete (splitStep.split as any)[implicitExpression];
+ split.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (split as any)[implicitExpression];
} else {
- splitStep.split.expression = CamelApi.createExpression(element?.split?.expression);
+ split.expression = CamelApi.createExpression(element?.expression);
}
- splitStep.split.steps = CamelApi.createSteps(element?.split?.steps);
- splitStep.uuid = element?.uuid ? element.uuid : splitStep.uuid;
- return splitStep;
+ split.steps = CamelApi.createSteps(element?.steps);
+ split.uuid = element?.uuid ? element.uuid : split.uuid;
+ return split;
}
- static createWireTap = (element: any): WireTapStep => {
- const wireTapStep = element ? new WireTapStep({...element.wireTap}) : new WireTapStep();
- wireTapStep.wireTap.body = CamelApi.createExpression(element?.wireTap?.body);
- wireTapStep.wireTap.setHeader = element && element?.wireTap ? element?.wireTap?.setHeader.map((x:any) => CamelApi.createSetHeader(x)) :[];
- wireTapStep.uuid = element?.uuid ? element.uuid : wireTapStep.uuid;
- return wireTapStep;
+ static createWireTap = (element: any): WireTap => {
+ const wireTap = element ? new WireTap({...element}) : new WireTap();
+ wireTap.body = CamelApi.createExpression(element?.wireTap?.body);
+ wireTap.setHeader = element && element?.wireTap ? element?.wireTap?.setHeader.map((x:any) => CamelApi.createSetHeader(x)) :[];
+ wireTap.uuid = element?.uuid ? element.uuid : wireTap.uuid;
+ return wireTap;
}
- static createMulticast = (element: any): MulticastStep => {
- const multicastStep = element ? new MulticastStep({...element.multicast}) : new MulticastStep();
- multicastStep.multicast.steps = CamelApi.createSteps(element?.multicast?.steps);
- multicastStep.uuid = element?.uuid ? element.uuid : multicastStep.uuid;
- return multicastStep;
+ static createMulticast = (element: any): Multicast => {
+ const multicast = element ? new Multicast({...element}) : new Multicast();
+ multicast.steps = CamelApi.createSteps(element?.steps);
+ multicast.uuid = element?.uuid ? element.uuid : multicast.uuid;
+ return multicast;
}
- static createStop = (element: any): StopStep => {
- const stopStep = element ? new StopStep({...element.stop}) : new StopStep();
- stopStep.uuid = element?.uuid ? element.uuid : stopStep.uuid;
- return stopStep;
+ static createStop = (element: any): Stop => {
+ const stop = element ? new Stop({...element}) : new Stop();
+ stop.uuid = element?.uuid ? element.uuid : stop.uuid;
+ return stop;
}
- static createSetBody = (element: any): SetBodyStep => {
- const setBodyStep = element ? new SetBodyStep({...element.setBody}) : new SetBodyStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.setBody);
+ static createSetBody = (element: any): SetBody => {
+ const setBody = element ? new SetBody({...element}) : new SetBody();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- setBodyStep.setBody.expression = new Expression({[implicitExpression]: element.setBody[implicitExpression]});
- delete (setBodyStep.setBody as any)[implicitExpression];
+ setBody.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (setBody as any)[implicitExpression];
} else {
- setBodyStep.setBody.expression = CamelApi.createExpression(element?.setBody?.expression);
+ setBody.expression = CamelApi.createExpression(element?.expression);
}
- setBodyStep.uuid = element?.uuid ? element.uuid : setBodyStep.uuid;
- return setBodyStep;
+ setBody.uuid = element?.uuid ? element.uuid : setBody.uuid;
+ return setBody;
}
- static createSort = (element: any): SortStep => {
- const sortStep = element ? new SortStep({...element.sort}) : new SortStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.sort);
+ static createSort = (element: any): Sort => {
+ const sort = element ? new Sort({...element}) : new Sort();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- sortStep.sort.expression = new Expression({[implicitExpression]: element.sort[implicitExpression]});
- delete (sortStep.sort as any)[implicitExpression];
+ sort.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (sort as any)[implicitExpression];
} else {
- sortStep.sort.expression = CamelApi.createExpression(element?.sort?.expression);
+ sort.expression = CamelApi.createExpression(element?.expression);
}
- sortStep.uuid = element?.uuid ? element.uuid : sortStep.uuid;
- return sortStep;
+ sort.uuid = element?.uuid ? element.uuid : sort.uuid;
+ return sort;
}
- static createInterceptFrom = (element: any): InterceptFromStep => {
- const interceptFromStep = element ? new InterceptFromStep({...element.interceptFrom}) : new InterceptFromStep();
- interceptFromStep.interceptFrom.steps = CamelApi.createSteps(element?.interceptFrom?.steps);
- interceptFromStep.uuid = element?.uuid ? element.uuid : interceptFromStep.uuid;
- return interceptFromStep;
+ static createInterceptFrom = (element: any): InterceptFrom => {
+ const interceptFrom = element ? new InterceptFrom({...element}) : new InterceptFrom();
+ interceptFrom.steps = CamelApi.createSteps(element?.steps);
+ interceptFrom.uuid = element?.uuid ? element.uuid : interceptFrom.uuid;
+ return interceptFrom;
}
- static createThrowException = (element: any): ThrowExceptionStep => {
- const throwExceptionStep = element ? new ThrowExceptionStep({...element.throwException}) : new ThrowExceptionStep();
- throwExceptionStep.uuid = element?.uuid ? element.uuid : throwExceptionStep.uuid;
- return throwExceptionStep;
+ static createThrowException = (element: any): ThrowException => {
+ const throwException = element ? new ThrowException({...element}) : new ThrowException();
+ throwException.uuid = element?.uuid ? element.uuid : throwException.uuid;
+ return throwException;
}
- static createTo = (element: any): ToStep => {
- if (typeof element.to !== 'object') element.to = {uri: element.to};
- if (element && element.to && typeof element.to === 'string') element.to = {uri: element.to};
- const toStep = element ? new ToStep({...element.to}) : new ToStep();
- toStep.uuid = element?.uuid ? element.uuid : toStep.uuid;
- return toStep;
+ static createTo = (element: any): To => {
+ if (typeof element !== 'object') element = {uri: element};
+ if (element && typeof element === 'string') element = {uri: element};
+ const to = element ? new To({...element}) : new To();
+ to.uuid = element?.uuid ? element.uuid : to.uuid;
+ return to;
}
- static createFilter = (element: any): FilterStep => {
- const filterStep = element ? new FilterStep({...element.filter}) : new FilterStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.filter);
+ static createFilter = (element: any): Filter => {
+ const filter = element ? new Filter({...element}) : new Filter();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- filterStep.filter.expression = new Expression({[implicitExpression]: element.filter[implicitExpression]});
- delete (filterStep.filter as any)[implicitExpression];
+ filter.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (filter as any)[implicitExpression];
} else {
- filterStep.filter.expression = CamelApi.createExpression(element?.filter?.expression);
+ filter.expression = CamelApi.createExpression(element?.expression);
}
- filterStep.filter.steps = CamelApi.createSteps(element?.filter?.steps);
- filterStep.uuid = element?.uuid ? element.uuid : filterStep.uuid;
- return filterStep;
+ filter.steps = CamelApi.createSteps(element?.steps);
+ filter.uuid = element?.uuid ? element.uuid : filter.uuid;
+ return filter;
}
- static createServiceCall = (element: any): ServiceCallStep => {
- if (element && element.serviceCall && typeof element.serviceCall === 'string') element.serviceCall = {name: element.serviceCall};
- const serviceCallStep = element ? new ServiceCallStep({...element.serviceCall}) : new ServiceCallStep();
- serviceCallStep.uuid = element?.uuid ? element.uuid : serviceCallStep.uuid;
- return serviceCallStep;
+ static createServiceCall = (element: any): ServiceCall => {
+ if (element && typeof element === 'string') element = {name: element};
+ const serviceCall = element ? new ServiceCall({...element}) : new ServiceCall();
+ serviceCall.uuid = element?.uuid ? element.uuid : serviceCall.uuid;
+ return serviceCall;
}
- static createThrottle = (element: any): ThrottleStep => {
- const throttleStep = element ? new ThrottleStep({...element.throttle}) : new ThrottleStep();
- throttleStep.throttle.correlationExpression = CamelApi.createExpression(element?.throttle?.correlationExpression);
- const implicitExpression = CamelApi.getExpressionLanguage(element.throttle);
+ static createThrottle = (element: any): Throttle => {
+ const throttle = element ? new Throttle({...element}) : new Throttle();
+ throttle.correlationExpression = CamelApi.createExpression(element?.throttle?.correlationExpression);
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- throttleStep.throttle.expression = new Expression({[implicitExpression]: element.throttle[implicitExpression]});
- delete (throttleStep.throttle as any)[implicitExpression];
+ throttle.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (throttle as any)[implicitExpression];
} else {
- throttleStep.throttle.expression = CamelApi.createExpression(element?.throttle?.expression);
+ throttle.expression = CamelApi.createExpression(element?.expression);
}
- throttleStep.uuid = element?.uuid ? element.uuid : throttleStep.uuid;
- return throttleStep;
+ throttle.uuid = element?.uuid ? element.uuid : throttle.uuid;
+ return throttle;
}
- static createWhenSkipSendToEndpoint = (element: any): WhenSkipSendToEndpointStep => {
- const whenSkipSendToEndpointStep = element ? new WhenSkipSendToEndpointStep({...element.whenSkipSendToEndpoint}) : new WhenSkipSendToEndpointStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.whenSkipSendToEndpoint);
+ static createWhenSkipSendToEndpoint = (element: any): WhenSkipSendToEndpoint => {
+ const whenSkipSendToEndpoint = element ? new WhenSkipSendToEndpoint({...element}) : new WhenSkipSendToEndpoint();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- whenSkipSendToEndpointStep.whenSkipSendToEndpoint.expression = new Expression({[implicitExpression]: element.whenSkipSendToEndpoint[implicitExpression]});
- delete (whenSkipSendToEndpointStep.whenSkipSendToEndpoint as any)[implicitExpression];
+ whenSkipSendToEndpoint.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (whenSkipSendToEndpoint as any)[implicitExpression];
} else {
- whenSkipSendToEndpointStep.whenSkipSendToEndpoint.expression = CamelApi.createExpression(element?.whenSkipSendToEndpoint?.expression);
+ whenSkipSendToEndpoint.expression = CamelApi.createExpression(element?.expression);
}
- whenSkipSendToEndpointStep.whenSkipSendToEndpoint.steps = CamelApi.createSteps(element?.whenSkipSendToEndpoint?.steps);
- whenSkipSendToEndpointStep.uuid = element?.uuid ? element.uuid : whenSkipSendToEndpointStep.uuid;
- return whenSkipSendToEndpointStep;
+ whenSkipSendToEndpoint.steps = CamelApi.createSteps(element?.steps);
+ whenSkipSendToEndpoint.uuid = element?.uuid ? element.uuid : whenSkipSendToEndpoint.uuid;
+ return whenSkipSendToEndpoint;
}
- static createRemoveProperties = (element: any): RemovePropertiesStep => {
- if (element && element.removeProperties && typeof element.removeProperties === 'string') element.removeProperties = {pattern: element.removeProperties};
- const removePropertiesStep = element ? new RemovePropertiesStep({...element.removeProperties}) : new RemovePropertiesStep();
- removePropertiesStep.uuid = element?.uuid ? element.uuid : removePropertiesStep.uuid;
- return removePropertiesStep;
+ static createRemoveProperties = (element: any): RemoveProperties => {
+ if (element && typeof element === 'string') element = {pattern: element};
+ const removeProperties = element ? new RemoveProperties({...element}) : new RemoveProperties();
+ removeProperties.uuid = element?.uuid ? element.uuid : removeProperties.uuid;
+ return removeProperties;
}
- static createSetHeader = (element: any): SetHeaderStep => {
- const setHeaderStep = element ? new SetHeaderStep({...element.setHeader}) : new SetHeaderStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.setHeader);
+ static createSetHeader = (element: any): SetHeader => {
+ const setHeader = element ? new SetHeader({...element}) : new SetHeader();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- setHeaderStep.setHeader.expression = new Expression({[implicitExpression]: element.setHeader[implicitExpression]});
- delete (setHeaderStep.setHeader as any)[implicitExpression];
+ setHeader.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (setHeader as any)[implicitExpression];
} else {
- setHeaderStep.setHeader.expression = CamelApi.createExpression(element?.setHeader?.expression);
+ setHeader.expression = CamelApi.createExpression(element?.expression);
}
- setHeaderStep.uuid = element?.uuid ? element.uuid : setHeaderStep.uuid;
- return setHeaderStep;
+ setHeader.uuid = element?.uuid ? element.uuid : setHeader.uuid;
+ return setHeader;
}
- static createChoice = (element: any): ChoiceStep => {
- const choiceStep = element ? new ChoiceStep({...element.choice}) : new ChoiceStep();
- if (element?.choice?.otherwise !== undefined){
- choiceStep.choice.otherwise = CamelApi.createOtherwise(element?.choice?.otherwise);
+ static createChoice = (element: any): Choice => {
+ const choiceStep = element ? new Choice({...element}) : new Choice();
+ if (element?.otherwise !== undefined){
+ choiceStep.otherwise = CamelApi.createOtherwise(element?.otherwise);
}
- choiceStep.choice.when = element && element?.choice ? element?.choice?.when.map((x:any) => CamelApi.createWhen(x)) :[]
+ choiceStep.when = element && element?.when ? element?.when.map((x:any) => CamelApi.createWhen(x)) :[]
choiceStep.uuid = element?.uuid ? element.uuid : choiceStep.uuid
return choiceStep
}
- static createAggregate = (element: any): AggregateStep => {
- const aggregateStep = element ? new AggregateStep({...element.aggregate}) : new AggregateStep();
- aggregateStep.aggregate.completionPredicate = CamelApi.createExpression(element?.aggregate?.completionPredicate);
- aggregateStep.aggregate.completionSizeExpression = CamelApi.createExpression(element?.aggregate?.completionSizeExpression);
- aggregateStep.aggregate.completionTimeoutExpression = CamelApi.createExpression(element?.aggregate?.completionTimeoutExpression);
- aggregateStep.aggregate.correlationExpression = CamelApi.createExpression(element?.aggregate?.correlationExpression);
- aggregateStep.aggregate.steps = CamelApi.createSteps(element?.aggregate?.steps);
- aggregateStep.uuid = element?.uuid ? element.uuid : aggregateStep.uuid;
- return aggregateStep;
+ static createAggregate = (element: any): Aggregate => {
+ const aggregate = element ? new Aggregate({...element}) : new Aggregate();
+ aggregate.completionPredicate = CamelApi.createExpression(element?.aggregate?.completionPredicate);
+ aggregate.completionSizeExpression = CamelApi.createExpression(element?.aggregate?.completionSizeExpression);
+ aggregate.completionTimeoutExpression = CamelApi.createExpression(element?.aggregate?.completionTimeoutExpression);
+ aggregate.correlationExpression = CamelApi.createExpression(element?.aggregate?.correlationExpression);
+ aggregate.steps = CamelApi.createSteps(element?.steps);
+ aggregate.uuid = element?.uuid ? element.uuid : aggregate.uuid;
+ return aggregate;
}
- static createRemoveProperty = (element: any): RemovePropertyStep => {
- if (element && element.removeProperty && typeof element.removeProperty === 'string') element.removeProperty = {propertyName: element.removeProperty};
- const removePropertyStep = element ? new RemovePropertyStep({...element.removeProperty}) : new RemovePropertyStep();
- removePropertyStep.uuid = element?.uuid ? element.uuid : removePropertyStep.uuid;
- return removePropertyStep;
+ static createRemoveProperty = (element: any): RemoveProperty => {
+ if (element && typeof element === 'string') element = {propertyName: element};
+ const removeProperty = element ? new RemoveProperty({...element}) : new RemoveProperty();
+ removeProperty.uuid = element?.uuid ? element.uuid : removeProperty.uuid;
+ return removeProperty;
}
- static createRemoveHeader = (element: any): RemoveHeaderStep => {
- const removeHeaderStep = element ? new RemoveHeaderStep({...element.removeHeader}) : new RemoveHeaderStep();
- removeHeaderStep.uuid = element?.uuid ? element.uuid : removeHeaderStep.uuid;
- return removeHeaderStep;
+ static createRemoveHeader = (element: any): RemoveHeader => {
+ const removeHeader = element ? new RemoveHeader({...element}) : new RemoveHeader();
+ removeHeader.uuid = element?.uuid ? element.uuid : removeHeader.uuid;
+ return removeHeader;
}
- static createScript = (element: any): ScriptStep => {
- const scriptStep = element ? new ScriptStep({...element.script}) : new ScriptStep();
- const implicitExpression = CamelApi.getExpressionLanguage(element.script);
+ static createScript = (element: any): Script => {
+ const script = element ? new Script({...element}) : new Script();
+ const implicitExpression = CamelApi.getExpressionLanguage(element);
if (implicitExpression){
- scriptStep.script.expression = new Expression({[implicitExpression]: element.script[implicitExpression]});
- delete (scriptStep.script as any)[implicitExpression];
+ script.expression = new Expression({[implicitExpression]: element[implicitExpression]});
+ delete (script as any)[implicitExpression];
} else {
- scriptStep.script.expression = CamelApi.createExpression(element?.script?.expression);
+ script.expression = CamelApi.createExpression(element?.expression);
}
- scriptStep.uuid = element?.uuid ? element.uuid : scriptStep.uuid;
- return scriptStep;
- }
-
- static createDoTry = (element: any): DoTryStep => {
- const doTryStep = element ? new DoTryStep({...element.doTry}) : new DoTryStep();
- doTryStep.doTry.doCatch = element && element?.doTry ? element?.doTry?.doCatch.map((x:any) => CamelApi.createDoCatch(x)) :[];
- doTryStep.doTry.doFinally = CamelApi.createDoFinally(element?.doTry?.doFinally);
- doTryStep.doTry.steps = CamelApi.createSteps(element?.doTry?.steps);
- doTryStep.uuid = element?.uuid ? element.uuid : doTryStep.uuid;
- return doTryStep;
- }
-
- static createSetExchangePattern = (element: any): SetExchangePatternStep => {
- if (element && element.setExchangePattern && typeof element.setExchangePattern === 'string') element.setExchangePattern = {pattern: element.setExchangePattern};
- const setExchangePatternStep = element ? new SetExchangePatternStep({...element.setExchangePattern}) : new SetExchangePatternStep();
- setExchangePatternStep.uuid = element?.uuid ? element.uuid : setExchangePatternStep.uuid;
- return setExchangePatternStep;
- }
-
- static createTransacted = (element: any): TransactedStep => {
- const transactedStep = element ? new TransactedStep({...element.transacted}) : new TransactedStep();
- transactedStep.transacted.steps = CamelApi.createSteps(element?.transacted?.steps);
- transactedStep.uuid = element?.uuid ? element.uuid : transactedStep.uuid;
- return transactedStep;
- }
-
- static createPipeline = (element: any): PipelineStep => {
- const pipelineStep = element ? new PipelineStep({...element.pipeline}) : new PipelineStep();
- pipelineStep.pipeline.steps = CamelApi.createSteps(element?.pipeline?.steps);
- pipelineStep.uuid = element?.uuid ? element.uuid : pipelineStep.uuid;
- return pipelineStep;
- }
-
- static createUnmarshal = (element: any): UnmarshalStep => {
- const unmarshalStep = element ? new UnmarshalStep({...element.unmarshal}) : new UnmarshalStep();
- if (element.unmarshal?.any23 !== undefined) unmarshalStep.unmarshal.any23 = new dataFormat.Any23DataFormat(element.unmarshal.any23);
- if (element.unmarshal?.asn1 !== undefined) unmarshalStep.unmarshal.asn1 = new dataFormat.ASN1DataFormat(element.unmarshal.asn1);
- if (element.unmarshal?.avro !== undefined) unmarshalStep.unmarshal.avro = new dataFormat.AvroDataFormat(element.unmarshal.avro);
- if (element.unmarshal?.barcode !== undefined) unmarshalStep.unmarshal.barcode = new dataFormat.BarcodeDataFormat(element.unmarshal.barcode);
- if (element.unmarshal?.base64 !== undefined) unmarshalStep.unmarshal.base64 = new dataFormat.Base64DataFormat(element.unmarshal.base64);
- if (element.unmarshal?.beanio !== undefined) unmarshalStep.unmarshal.beanio = new dataFormat.BeanioDataFormat(element.unmarshal.beanio);
- if (element.unmarshal?.bindy !== undefined) unmarshalStep.unmarshal.bindy = new dataFormat.BindyDataFormat(element.unmarshal.bindy);
- if (element.unmarshal?.cbor !== undefined) unmarshalStep.unmarshal.cbor = new dataFormat.CBORDataFormat(element.unmarshal.cbor);
- if (element.unmarshal?.crypto !== undefined) unmarshalStep.unmarshal.crypto = new dataFormat.CryptoDataFormat(element.unmarshal.crypto);
- if (element.unmarshal?.csv !== undefined) unmarshalStep.unmarshal.csv = new dataFormat.CsvDataFormat(element.unmarshal.csv);
- if (element.unmarshal?.custom !== undefined) unmarshalStep.unmarshal.custom = new dataFormat.CustomDataFormat(element.unmarshal.custom);
- if (element.unmarshal?.fhirJson !== undefined) unmarshalStep.unmarshal.fhirJson = new dataFormat.FhirJsonDataFormat(element.unmarshal.fhirJson);
- if (element.unmarshal?.fhirXml !== undefined) unmarshalStep.unmarshal.fhirXml = new dataFormat.FhirXmlDataFormat(element.unmarshal.fhirXml);
- if (element.unmarshal?.flatpack !== undefined) unmarshalStep.unmarshal.flatpack = new dataFormat.FlatpackDataFormat(element.unmarshal.flatpack);
- if (element.unmarshal?.grok !== undefined) unmarshalStep.unmarshal.grok = new dataFormat.GrokDataFormat(element.unmarshal.grok);
- if (element.unmarshal?.gzip !== undefined) unmarshalStep.unmarshal.gzip = new dataFormat.GzipDataFormat(element.unmarshal.gzip);
- if (element.unmarshal?.hl7 !== undefined) unmarshalStep.unmarshal.hl7 = new dataFormat.HL7DataFormat(element.unmarshal.hl7);
- if (element.unmarshal?.ical !== undefined) unmarshalStep.unmarshal.ical = new dataFormat.IcalDataFormat(element.unmarshal.ical);
- if (element.unmarshal?.jacksonxml !== undefined) unmarshalStep.unmarshal.jacksonxml = new dataFormat.JacksonXMLDataFormat(element.unmarshal.jacksonxml);
- if (element.unmarshal?.jaxb !== undefined) unmarshalStep.unmarshal.jaxb = new dataFormat.JaxbDataFormat(element.unmarshal.jaxb);
- if (element.unmarshal?.json !== undefined) unmarshalStep.unmarshal.json = new dataFormat.JsonDataFormat(element.unmarshal.json);
- if (element.unmarshal?.jsonApi !== undefined) unmarshalStep.unmarshal.jsonApi = new dataFormat.JsonApiDataFormat(element.unmarshal.jsonApi);
- if (element.unmarshal?.lzf !== undefined) unmarshalStep.unmarshal.lzf = new dataFormat.LZFDataFormat(element.unmarshal.lzf);
- if (element.unmarshal?.mimeMultipart !== undefined) unmarshalStep.unmarshal.mimeMultipart = new dataFormat.MimeMultipartDataFormat(element.unmarshal.mimeMultipart);
- if (element.unmarshal?.pgp !== undefined) unmarshalStep.unmarshal.pgp = new dataFormat.PGPDataFormat(element.unmarshal.pgp);
- if (element.unmarshal?.protobuf !== undefined) unmarshalStep.unmarshal.protobuf = new dataFormat.ProtobufDataFormat(element.unmarshal.protobuf);
- if (element.unmarshal?.rss !== undefined) unmarshalStep.unmarshal.rss = new dataFormat.RssDataFormat(element.unmarshal.rss);
- if (element.unmarshal?.secureXml !== undefined) unmarshalStep.unmarshal.secureXml = new dataFormat.XMLSecurityDataFormat(element.unmarshal.secureXml);
- if (element.unmarshal?.soapjaxb !== undefined) unmarshalStep.unmarshal.soapjaxb = new dataFormat.SoapJaxbDataFormat(element.unmarshal.soapjaxb);
- if (element.unmarshal?.syslog !== undefined) unmarshalStep.unmarshal.syslog = new dataFormat.SyslogDataFormat(element.unmarshal.syslog);
- if (element.unmarshal?.tarfile !== undefined) unmarshalStep.unmarshal.tarfile = new dataFormat.TarFileDataFormat(element.unmarshal.tarfile);
- if (element.unmarshal?.thrift !== undefined) unmarshalStep.unmarshal.thrift = new dataFormat.ThriftDataFormat(element.unmarshal.thrift);
- if (element.unmarshal?.tidyMarkup !== undefined) unmarshalStep.unmarshal.tidyMarkup = new dataFormat.TidyMarkupDataFormat(element.unmarshal.tidyMarkup);
- if (element.unmarshal?.univocityCsv !== undefined) unmarshalStep.unmarshal.univocityCsv = new dataFormat.UniVocityCsvDataFormat(element.unmarshal.univocityCsv);
- if (element.unmarshal?.univocityFixed !== undefined) unmarshalStep.unmarshal.univocityFixed = new dataFormat.UniVocityFixedWidthDataFormat(element.unmarshal.univocityFixed);
- if (element.unmarshal?.univocityTsv !== undefined) unmarshalStep.unmarshal.univocityTsv = new dataFormat.UniVocityTsvDataFormat(element.unmarshal.univocityTsv);
- if (element.unmarshal?.xmlrpc !== undefined) unmarshalStep.unmarshal.xmlrpc = new dataFormat.XmlRpcDataFormat(element.unmarshal.xmlrpc);
- if (element.unmarshal?.xstream !== undefined) unmarshalStep.unmarshal.xstream = new dataFormat.XStreamDataFormat(element.unmarshal.xstream);
- if (element.unmarshal?.yaml !== undefined) unmarshalStep.unmarshal.yaml = new dataFormat.YAMLDataFormat(element.unmarshal.yaml);
- if (element.unmarshal?.zip !== undefined) unmarshalStep.unmarshal.zip = new dataFormat.ZipDeflaterDataFormat(element.unmarshal.zip);
- if (element.unmarshal?.zipfile !== undefined) unmarshalStep.unmarshal.zipfile = new dataFormat.ZipFileDataFormat(element.unmarshal.zipfile);
- unmarshalStep.uuid = element?.uuid ? element.uuid : unmarshalStep.uuid;
- return unmarshalStep;
- }
-
- static createSteps = (elements: any[] | undefined): ProcessorStep[] => {
- const result: ProcessorStep[] = []
+ script.uuid = element?.uuid ? element.uuid : script.uuid;
+ return script;
+ }
+
+ static createDoTry = (element: any): DoTry => {
+ const doTry = element ? new DoTry({...element}) : new DoTry();
+ doTry.doCatch = element && element?.doTry ? element?.doTry?.doCatch.map((x:any) => CamelApi.createDoCatch(x)) :[];
+ doTry.doFinally = CamelApi.createDoFinally(element?.doTry?.doFinally);
+ doTry.steps = CamelApi.createSteps(element?.steps);
+ doTry.uuid = element?.uuid ? element.uuid : doTry.uuid;
+ return doTry;
+ }
+
+ static createSetExchangePattern = (element: any): SetExchangePattern => {
+ if (element && typeof element === 'string') element = {pattern: element};
+ const setExchangePattern = element ? new SetExchangePattern({...element}) : new SetExchangePattern();
+ setExchangePattern.uuid = element?.uuid ? element.uuid : setExchangePattern.uuid;
+ return setExchangePattern;
+ }
+
+ static createTransacted = (element: any): Transacted => {
+ const transacted = element ? new Transacted({...element}) : new Transacted();
+ transacted.steps = CamelApi.createSteps(element?.steps);
+ transacted.uuid = element?.uuid ? element.uuid : transacted.uuid;
+ return transacted;
+ }
+
+ static createPipeline = (element: any): Pipeline => {
+ const pipeline = element ? new Pipeline({...element}) : new Pipeline();
+ pipeline.steps = CamelApi.createSteps(element?.steps);
+ pipeline.uuid = element?.uuid ? element.uuid : pipeline.uuid;
+ return pipeline;
+ }
+
+ static createUnmarshal = (element: any): Unmarshal => {
+ const unmarshal = element ? new Unmarshal({...element}) : new Unmarshal();
+ if (element.any23 !== undefined) unmarshal.any23 = new dataFormat.Any23DataFormat(element.any23);
+ if (element.asn1 !== undefined) unmarshal.asn1 = new dataFormat.ASN1DataFormat(element.asn1);
+ if (element.avro !== undefined) unmarshal.avro = new dataFormat.AvroDataFormat(element.avro);
+ if (element.barcode !== undefined) unmarshal.barcode = new dataFormat.BarcodeDataFormat(element.barcode);
+ if (element.base64 !== undefined) unmarshal.base64 = new dataFormat.Base64DataFormat(element.base64);
+ if (element.beanio !== undefined) unmarshal.beanio = new dataFormat.BeanioDataFormat(element.beanio);
+ if (element.bindy !== undefined) unmarshal.bindy = new dataFormat.BindyDataFormat(element.bindy);
+ if (element.cbor !== undefined) unmarshal.cbor = new dataFormat.CBORDataFormat(element.cbor);
+ if (element.crypto !== undefined) unmarshal.crypto = new dataFormat.CryptoDataFormat(element.crypto);
+ if (element.csv !== undefined) unmarshal.csv = new dataFormat.CsvDataFormat(element.csv);
+ if (element.custom !== undefined) unmarshal.custom = new dataFormat.CustomDataFormat(element.custom);
+ if (element.fhirJson !== undefined) unmarshal.fhirJson = new dataFormat.FhirJsonDataFormat(element.fhirJson);
+ if (element.fhirXml !== undefined) unmarshal.fhirXml = new dataFormat.FhirXmlDataFormat(element.fhirXml);
+ if (element.flatpack !== undefined) unmarshal.flatpack = new dataFormat.FlatpackDataFormat(element.flatpack);
+ if (element.grok !== undefined) unmarshal.grok = new dataFormat.GrokDataFormat(element.grok);
+ if (element.gzip !== undefined) unmarshal.gzip = new dataFormat.GzipDataFormat(element.gzip);
+ if (element.hl7 !== undefined) unmarshal.hl7 = new dataFormat.HL7DataFormat(element.hl7);
+ if (element.ical !== undefined) unmarshal.ical = new dataFormat.IcalDataFormat(element.ical);
+ if (element.jacksonxml !== undefined) unmarshal.jacksonxml = new dataFormat.JacksonXMLDataFormat(element.jacksonxml);
+ if (element.jaxb !== undefined) unmarshal.jaxb = new dataFormat.JaxbDataFormat(element.jaxb);
+ if (element.json !== undefined) unmarshal.json = new dataFormat.JsonDataFormat(element.json);
+ if (element.jsonApi !== undefined) unmarshal.jsonApi = new dataFormat.JsonApiDataFormat(element.jsonApi);
+ if (element.lzf !== undefined) unmarshal.lzf = new dataFormat.LZFDataFormat(element.lzf);
+ if (element.mimeMultipart !== undefined) unmarshal.mimeMultipart = new dataFormat.MimeMultipartDataFormat(element.mimeMultipart);
+ if (element.pgp !== undefined) unmarshal.pgp = new dataFormat.PGPDataFormat(element.pgp);
+ if (element.protobuf !== undefined) unmarshal.protobuf = new dataFormat.ProtobufDataFormat(element.protobuf);
+ if (element.rss !== undefined) unmarshal.rss = new dataFormat.RssDataFormat(element.rss);
+ if (element.secureXml !== undefined) unmarshal.secureXml = new dataFormat.XMLSecurityDataFormat(element.secureXml);
+ if (element.soapjaxb !== undefined) unmarshal.soapjaxb = new dataFormat.SoapJaxbDataFormat(element.soapjaxb);
+ if (element.syslog !== undefined) unmarshal.syslog = new dataFormat.SyslogDataFormat(element.syslog);
+ if (element.tarfile !== undefined) unmarshal.tarfile = new dataFormat.TarFileDataFormat(element.tarfile);
+ if (element.thrift !== undefined) unmarshal.thrift = new dataFormat.ThriftDataFormat(element.thrift);
+ if (element.tidyMarkup !== undefined) unmarshal.tidyMarkup = new dataFormat.TidyMarkupDataFormat(element.tidyMarkup);
+ if (element.univocityCsv !== undefined) unmarshal.univocityCsv = new dataFormat.UniVocityCsvDataFormat(element.univocityCsv);
+ if (element.univocityFixed !== undefined) unmarshal.univocityFixed = new dataFormat.UniVocityFixedWidthDataFormat(element.univocityFixed);
+ if (element.univocityTsv !== undefined) unmarshal.univocityTsv = new dataFormat.UniVocityTsvDataFormat(element.univocityTsv);
+ if (element.xmlrpc !== undefined) unmarshal.xmlrpc = new dataFormat.XmlRpcDataFormat(element.xmlrpc);
+ if (element.xstream !== undefined) unmarshal.xstream = new dataFormat.XStreamDataFormat(element.xstream);
+ if (element.yaml !== undefined) unmarshal.yaml = new dataFormat.YAMLDataFormat(element.yaml);
+ if (element.zip !== undefined) unmarshal.zip = new dataFormat.ZipDeflaterDataFormat(element.zip);
+ if (element.zipfile !== undefined) unmarshal.zipfile = new dataFormat.ZipFileDataFormat(element.zipfile);
+ unmarshal.uuid = element?.uuid ? element.uuid : unmarshal.uuid;
+ return unmarshal;
+ }
+
+ static createSteps = (elements: any[] | undefined): CamelElement[] => {
+ const result: CamelElement[] = []
if (elements !== undefined){
elements.forEach(e => {
- const stepName = Object.keys(e).filter(key => !['uuid', 'dslName'].includes(key))[0];
- result.push(CamelApi.createStep(CamelApi.camelizeName(stepName, '-', true), e));
+ result.push(CamelApi.createStep(CamelUtil.camelizeName(e.dslName, '-', true), e));
})
}
return result
}
- static elementFromStep = (step: CamelElement): CamelElement => {
- switch (step.dslName){
- case 'fromStep' : return (step as FromStep).from
- case 'policyStep': return (step as PolicyStep).policy
- case 'setPropertyStep': return (step as SetPropertyStep).setProperty
- case 'sagaStep': return (step as SagaStep).saga
- case 'toDStep': return (step as ToDStep).toD
- case 'threadsStep': return (step as ThreadsStep).threads
- case 'interceptSendToEndpointStep': return (step as InterceptSendToEndpointStep).interceptSendToEndpoint
- case 'logStep': return (step as LogStep).log
- case 'loopStep': return (step as LoopStep).loop
- case 'delayStep': return (step as DelayStep).delay
- case 'sampleStep': return (step as SampleStep).sample
- case 'doFinallyStep': return (step as DoFinallyStep).doFinally
- case 'loadBalanceStep': return (step as LoadBalanceStep).loadBalance
- case 'validateStep': return (step as ValidateStep).validate
- case 'transformStep': return (step as TransformStep).transform
- case 'removeHeadersStep': return (step as RemoveHeadersStep).removeHeaders
- case 'idempotentConsumerStep': return (step as IdempotentConsumerStep).idempotentConsumer
- case 'interceptStep': return (step as InterceptStep).intercept
- case 'when': return (step as When)
- case 'processStep': return (step as ProcessStep).process
- case 'onFallbackStep': return (step as OnFallbackStep).onFallback
- case 'marshalStep': return (step as MarshalStep).marshal
- case 'onCompletionStep': return (step as OnCompletionStep).onCompletion
- case 'claimCheckStep': return (step as ClaimCheckStep).claimCheck
- case 'doCatchStep': return (step as DoCatchStep).doCatch
- case 'inOnlyStep': return (step as InOnlyStep).inOnly
- case 'convertBodyToStep': return (step as ConvertBodyToStep).convertBodyTo
- case 'circuitBreakerStep': return (step as CircuitBreakerStep).circuitBreaker
- case 'pollEnrichStep': return (step as PollEnrichStep).pollEnrich
- case 'otherwise': return (step as Otherwise)
- case 'resequenceStep': return (step as ResequenceStep).resequence
- case 'routingSlipStep': return (step as RoutingSlipStep).routingSlip
- case 'beanStep': return (step as BeanStep).bean
- case 'recipientListStep': return (step as RecipientListStep).recipientList
- case 'kameletStep': return (step as KameletStep).kamelet
- case 'dynamicRouterStep': return (step as DynamicRouterStep).dynamicRouter
- case 'rollbackStep': return (step as RollbackStep).rollback
- case 'inOutStep': return (step as InOutStep).inOut
- case 'enrichStep': return (step as EnrichStep).enrich
- case 'splitStep': return (step as SplitStep).split
- case 'wireTapStep': return (step as WireTapStep).wireTap
- case 'multicastStep': return (step as MulticastStep).multicast
- case 'stopStep': return (step as StopStep).stop
- case 'setBodyStep': return (step as SetBodyStep).setBody
- case 'sortStep': return (step as SortStep).sort
- case 'interceptFromStep': return (step as InterceptFromStep).interceptFrom
- case 'throwExceptionStep': return (step as ThrowExceptionStep).throwException
- case 'toStep': return (step as ToStep).to
- case 'filterStep': return (step as FilterStep).filter
- case 'serviceCallStep': return (step as ServiceCallStep).serviceCall
- case 'throttleStep': return (step as ThrottleStep).throttle
- case 'whenSkipSendToEndpointStep': return (step as WhenSkipSendToEndpointStep).whenSkipSendToEndpoint
- case 'removePropertiesStep': return (step as RemovePropertiesStep).removeProperties
- case 'setHeaderStep': return (step as SetHeaderStep).setHeader
- case 'choiceStep': return (step as ChoiceStep).choice
- case 'aggregateStep': return (step as AggregateStep).aggregate
- case 'removePropertyStep': return (step as RemovePropertyStep).removeProperty
- case 'removeHeaderStep': return (step as RemoveHeaderStep).removeHeader
- case 'scriptStep': return (step as ScriptStep).script
- case 'doTryStep': return (step as DoTryStep).doTry
- case 'setExchangePatternStep': return (step as SetExchangePatternStep).setExchangePattern
- case 'transactedStep': return (step as TransactedStep).transacted
- case 'pipelineStep': return (step as PipelineStep).pipeline
- case 'unmarshalStep': return (step as UnmarshalStep).unmarshal
- default : return new CamelElement('')
- }
- }
-
- static addStep = (steps: ProcessorStep[], step: ProcessorStep, parentId: string, position?: number): ProcessorStep[] => {
- const result: ProcessorStep[] = [];
+ static addStep = (steps: CamelElement[], step: CamelElement, parentId: string, position?: number): CamelElement[] => {
+ const result: CamelElement[] = [];
steps.forEach(el => {
switch (el.dslName) {
- case 'policyStep':
- const policyChildren = (el as PolicyStep).policy?.steps || [];
+ case 'policy':
+ const policyChildren = (el as Policy).steps || [];
if (el.uuid === parentId) position !== undefined ? policyChildren.splice(position, 0, step) : policyChildren.push(step);
- else (el as PolicyStep).policy.steps = CamelApi.addStep(policyChildren, step, parentId, position);
+ else (el as Policy).steps = CamelApi.addStep(policyChildren, step, parentId, position);
break;
- case 'choiceStep':
- const choiceChildren = (el as ChoiceStep).choice?.when || [];
+ case 'choice':
+ const choiceChildren = (el as Choice).when || [];
if (el.uuid === parentId && step.dslName === 'when') {
choiceChildren.push(step as When);
- (el as ChoiceStep).choice.when = choiceChildren;
- } else if (el.uuid === parentId && step.dslName === 'otherwise' && !(el as ChoiceStep).choice.otherwise) {
- (el as ChoiceStep).choice.otherwise = step;
+ (el as Choice).when = choiceChildren;
+ } else if (el.uuid === parentId && step.dslName === 'otherwise' && !(el as Choice).otherwise) {
+ (el as Choice).otherwise = step;
} else {
- (el as ChoiceStep).choice.when = CamelApi.addStep(choiceChildren, step, parentId, position) as When[];
- const otherwise = (el as ChoiceStep).choice.otherwise;
+ (el as Choice).when = CamelApi.addStep(choiceChildren, step, parentId, position) as When[];
+ const otherwise = (el as Choice).otherwise;
if (otherwise?.uuid === parentId){
otherwise.steps = otherwise.steps ? [...otherwise.steps] : [];
otherwise.steps.push(step);
- (el as ChoiceStep).choice.otherwise = otherwise
+ (el as Choice).otherwise = otherwise
} else if (otherwise && otherwise.steps && otherwise.steps.length > 0){
otherwise.steps = CamelApi.addStep(otherwise.steps, step, parentId, position);
- (el as ChoiceStep).choice.otherwise = otherwise;
+ (el as Choice).otherwise = otherwise;
}
}
break;
@@ -958,120 +856,120 @@ export class CamelApi {
if (el.uuid === parentId) position !== undefined ? otherwiseChildren.splice(position, 0, step) : otherwiseChildren.push(step);
else (el as Otherwise).steps = CamelApi.addStep(otherwiseChildren, step, parentId, position);
break;
- case 'fromStep':
- const fromChildren = (el as FromStep).from?.steps || [];
+ case 'from':
+ const fromChildren = (el as From).steps || [];
if (el.uuid === parentId) position !== undefined ? fromChildren.splice(position, 0, step) : fromChildren.push(step);
- else (el as FromStep).from.steps = CamelApi.addStep(fromChildren, step, parentId, position);
+ else (el as From).steps = CamelApi.addStep(fromChildren, step, parentId, position);
break;
- case 'onCompletionStep':
- const onCompletionChildren = (el as OnCompletionStep).onCompletion?.steps || [];
+ case 'onCompletion':
+ const onCompletionChildren = (el as OnCompletion).steps || [];
if (el.uuid === parentId) position !== undefined ? onCompletionChildren.splice(position, 0, step) : onCompletionChildren.push(step);
- else (el as OnCompletionStep).onCompletion.steps = CamelApi.addStep(onCompletionChildren, step, parentId, position);
+ else (el as OnCompletion).steps = CamelApi.addStep(onCompletionChildren, step, parentId, position);
break;
- case 'splitStep':
- const splitChildren = (el as SplitStep).split?.steps || [];
+ case 'split':
+ const splitChildren = (el as Split).steps || [];
if (el.uuid === parentId) position !== undefined ? splitChildren.splice(position, 0, step) : splitChildren.push(step);
- else (el as SplitStep).split.steps = CamelApi.addStep(splitChildren, step, parentId, position);
+ else (el as Split).steps = CamelApi.addStep(splitChildren, step, parentId, position);
break;
- case 'transactedStep':
- const transactedChildren = (el as TransactedStep).transacted?.steps || [];
+ case 'transacted':
+ const transactedChildren = (el as Transacted).steps || [];
if (el.uuid === parentId) position !== undefined ? transactedChildren.splice(position, 0, step) : transactedChildren.push(step);
- else (el as TransactedStep).transacted.steps = CamelApi.addStep(transactedChildren, step, parentId, position);
+ else (el as Transacted).steps = CamelApi.addStep(transactedChildren, step, parentId, position);
break;
- case 'interceptFromStep':
- const interceptFromChildren = (el as InterceptFromStep).interceptFrom?.steps || [];
+ case 'interceptFrom':
+ const interceptFromChildren = (el as InterceptFrom).steps || [];
if (el.uuid === parentId) position !== undefined ? interceptFromChildren.splice(position, 0, step) : interceptFromChildren.push(step);
- else (el as InterceptFromStep).interceptFrom.steps = CamelApi.addStep(interceptFromChildren, step, parentId, position);
+ else (el as InterceptFrom).steps = CamelApi.addStep(interceptFromChildren, step, parentId, position);
break;
- case 'doCatchStep':
- const doCatchChildren = (el as DoCatchStep).doCatch?.steps || [];
+ case 'doCatch':
+ const doCatchChildren = (el as DoCatch).steps || [];
if (el.uuid === parentId) position !== undefined ? doCatchChildren.splice(position, 0, step) : doCatchChildren.push(step);
- else (el as DoCatchStep).doCatch.steps = CamelApi.addStep(doCatchChildren, step, parentId, position);
+ else (el as DoCatch).steps = CamelApi.addStep(doCatchChildren, step, parentId, position);
break;
- case 'circuitBreakerStep':
- const circuitBreakerChildren = (el as CircuitBreakerStep).circuitBreaker?.steps || [];
+ case 'circuitBreaker':
+ const circuitBreakerChildren = (el as CircuitBreaker).steps || [];
if (el.uuid === parentId) position !== undefined ? circuitBreakerChildren.splice(position, 0, step) : circuitBreakerChildren.push(step);
- else (el as CircuitBreakerStep).circuitBreaker.steps = CamelApi.addStep(circuitBreakerChildren, step, parentId, position);
+ else (el as CircuitBreaker).steps = CamelApi.addStep(circuitBreakerChildren, step, parentId, position);
break;
- case 'interceptStep':
- const interceptChildren = (el as InterceptStep).intercept?.steps || [];
+ case 'intercept':
+ const interceptChildren = (el as Intercept).steps || [];
if (el.uuid === parentId) position !== undefined ? interceptChildren.splice(position, 0, step) : interceptChildren.push(step);
- else (el as InterceptStep).intercept.steps = CamelApi.addStep(interceptChildren, step, parentId, position);
+ else (el as Intercept).steps = CamelApi.addStep(interceptChildren, step, parentId, position);
break;
- case 'onFallbackStep':
- const onFallbackChildren = (el as OnFallbackStep).onFallback?.steps || [];
+ case 'onFallback':
+ const onFallbackChildren = (el as OnFallback).steps || [];
if (el.uuid === parentId) position !== undefined ? onFallbackChildren.splice(position, 0, step) : onFallbackChildren.push(step);
- else (el as OnFallbackStep).onFallback.steps = CamelApi.addStep(onFallbackChildren, step, parentId, position);
+ else (el as OnFallback).steps = CamelApi.addStep(onFallbackChildren, step, parentId, position);
break;
- case 'multicastStep':
- const multicastChildren = (el as MulticastStep).multicast?.steps || [];
+ case 'multicast':
+ const multicastChildren = (el as Multicast).steps || [];
if (el.uuid === parentId) position !== undefined ? multicastChildren.splice(position, 0, step) : multicastChildren.push(step);
- else (el as MulticastStep).multicast.steps = CamelApi.addStep(multicastChildren, step, parentId, position);
+ else (el as Multicast).steps = CamelApi.addStep(multicastChildren, step, parentId, position);
break;
- case 'loadBalanceStep':
- const loadBalanceChildren = (el as LoadBalanceStep).loadBalance?.steps || [];
+ case 'loadBalance':
+ const loadBalanceChildren = (el as LoadBalance).steps || [];
if (el.uuid === parentId) position !== undefined ? loadBalanceChildren.splice(position, 0, step) : loadBalanceChildren.push(step);
- else (el as LoadBalanceStep).loadBalance.steps = CamelApi.addStep(loadBalanceChildren, step, parentId, position);
+ else (el as LoadBalance).steps = CamelApi.addStep(loadBalanceChildren, step, parentId, position);
break;
- case 'whenSkipSendToEndpointStep':
- const whenSkipSendToEndpointChildren = (el as WhenSkipSendToEndpointStep).whenSkipSendToEndpoint?.steps || [];
+ case 'whenSkipSendToEndpoint':
+ const whenSkipSendToEndpointChildren = (el as WhenSkipSendToEndpoint).steps || [];
if (el.uuid === parentId) position !== undefined ? whenSkipSendToEndpointChildren.splice(position, 0, step) : whenSkipSendToEndpointChildren.push(step);
- else (el as WhenSkipSendToEndpointStep).whenSkipSendToEndpoint.steps = CamelApi.addStep(whenSkipSendToEndpointChildren, step, parentId, position);
+ else (el as WhenSkipSendToEndpoint).steps = CamelApi.addStep(whenSkipSendToEndpointChildren, step, parentId, position);
break;
- case 'loopStep':
- const loopChildren = (el as LoopStep).loop?.steps || [];
+ case 'loop':
+ const loopChildren = (el as Loop).steps || [];
if (el.uuid === parentId) position !== undefined ? loopChildren.splice(position, 0, step) : loopChildren.push(step);
- else (el as LoopStep).loop.steps = CamelApi.addStep(loopChildren, step, parentId, position);
+ else (el as Loop).steps = CamelApi.addStep(loopChildren, step, parentId, position);
break;
- case 'interceptSendToEndpointStep':
- const interceptSendToEndpointChildren = (el as InterceptSendToEndpointStep).interceptSendToEndpoint?.steps || [];
+ case 'interceptSendToEndpoint':
+ const interceptSendToEndpointChildren = (el as InterceptSendToEndpoint).steps || [];
if (el.uuid === parentId) position !== undefined ? interceptSendToEndpointChildren.splice(position, 0, step) : interceptSendToEndpointChildren.push(step);
- else (el as InterceptSendToEndpointStep).interceptSendToEndpoint.steps = CamelApi.addStep(interceptSendToEndpointChildren, step, parentId, position);
+ else (el as InterceptSendToEndpoint).steps = CamelApi.addStep(interceptSendToEndpointChildren, step, parentId, position);
break;
- case 'doTryStep':
- const doTryChildren = (el as DoTryStep).doTry?.steps || [];
+ case 'doTry':
+ const doTryChildren = (el as DoTry).steps || [];
if (el.uuid === parentId) position !== undefined ? doTryChildren.splice(position, 0, step) : doTryChildren.push(step);
- else (el as DoTryStep).doTry.steps = CamelApi.addStep(doTryChildren, step, parentId, position);
+ else (el as DoTry).steps = CamelApi.addStep(doTryChildren, step, parentId, position);
break;
- case 'resequenceStep':
- const resequenceChildren = (el as ResequenceStep).resequence?.steps || [];
+ case 'resequence':
+ const resequenceChildren = (el as Resequence).steps || [];
if (el.uuid === parentId) position !== undefined ? resequenceChildren.splice(position, 0, step) : resequenceChildren.push(step);
- else (el as ResequenceStep).resequence.steps = CamelApi.addStep(resequenceChildren, step, parentId, position);
+ else (el as Resequence).steps = CamelApi.addStep(resequenceChildren, step, parentId, position);
break;
- case 'pipelineStep':
- const pipelineChildren = (el as PipelineStep).pipeline?.steps || [];
+ case 'pipeline':
+ const pipelineChildren = (el as Pipeline).steps || [];
if (el.uuid === parentId) position !== undefined ? pipelineChildren.splice(position, 0, step) : pipelineChildren.push(step);
- else (el as PipelineStep).pipeline.steps = CamelApi.addStep(pipelineChildren, step, parentId, position);
+ else (el as Pipeline).steps = CamelApi.addStep(pipelineChildren, step, parentId, position);
break;
- case 'sagaStep':
- const sagaChildren = (el as SagaStep).saga?.steps || [];
+ case 'saga':
+ const sagaChildren = (el as Saga).steps || [];
if (el.uuid === parentId) position !== undefined ? sagaChildren.splice(position, 0, step) : sagaChildren.push(step);
- else (el as SagaStep).saga.steps = CamelApi.addStep(sagaChildren, step, parentId, position);
+ else (el as Saga).steps = CamelApi.addStep(sagaChildren, step, parentId, position);
break;
case 'when':
const whenChildren = (el as When).steps || [];
if (el.uuid === parentId) position !== undefined ? whenChildren.splice(position, 0, step) : whenChildren.push(step);
else (el as When).steps = CamelApi.addStep(whenChildren, step, parentId, position);
break;
- case 'doFinallyStep':
- const doFinallyChildren = (el as DoFinallyStep).doFinally?.steps || [];
+ case 'doFinally':
+ const doFinallyChildren = (el as DoFinally).steps || [];
if (el.uuid === parentId) position !== undefined ? doFinallyChildren.splice(position, 0, step) : doFinallyChildren.push(step);
- else (el as DoFinallyStep).doFinally.steps = CamelApi.addStep(doFinallyChildren, step, parentId, position);
+ else (el as DoFinally).steps = CamelApi.addStep(doFinallyChildren, step, parentId, position);
break;
- case 'filterStep':
- const filterChildren = (el as FilterStep).filter?.steps || [];
+ case 'filter':
+ const filterChildren = (el as Filter).steps || [];
if (el.uuid === parentId) position !== undefined ? filterChildren.splice(position, 0, step) : filterChildren.push(step);
- else (el as FilterStep).filter.steps = CamelApi.addStep(filterChildren, step, parentId, position);
+ else (el as Filter).steps = CamelApi.addStep(filterChildren, step, parentId, position);
break;
- case 'aggregateStep':
- const aggregateChildren = (el as AggregateStep).aggregate?.steps || [];
+ case 'aggregate':
+ const aggregateChildren = (el as Aggregate).steps || [];
if (el.uuid === parentId) position !== undefined ? aggregateChildren.splice(position, 0, step) : aggregateChildren.push(step);
- else (el as AggregateStep).aggregate.steps = CamelApi.addStep(aggregateChildren, step, parentId, position);
+ else (el as Aggregate).steps = CamelApi.addStep(aggregateChildren, step, parentId, position);
break;
- case 'idempotentConsumerStep':
- const idempotentConsumerChildren = (el as IdempotentConsumerStep).idempotentConsumer?.steps || [];
+ case 'idempotentConsumer':
+ const idempotentConsumerChildren = (el as IdempotentConsumer).steps || [];
if (el.uuid === parentId) position !== undefined ? idempotentConsumerChildren.splice(position, 0, step) : idempotentConsumerChildren.push(step);
- else (el as IdempotentConsumerStep).idempotentConsumer.steps = CamelApi.addStep(idempotentConsumerChildren, step, parentId, position);
+ else (el as IdempotentConsumer).steps = CamelApi.addStep(idempotentConsumerChildren, step, parentId, position);
break;
}
result.push(el);
@@ -1079,47 +977,47 @@ export class CamelApi {
return result;
}
- static deleteStep = (steps: ProcessorStep[] | undefined, uuidToDelete: string): ProcessorStep[] => {
- const result: ProcessorStep[] = []
+ static deleteStep = (steps: CamelElement[] | undefined, uuidToDelete: string): CamelElement[] => {
+ const result: CamelElement[] = []
if (steps !== undefined){
steps.forEach(step => {
if (step.uuid !== uuidToDelete){
switch (step.dslName){
- case 'policyStep': (step as PolicyStep).policy.steps = CamelApi.deleteStep((step as PolicyStep).policy.steps, uuidToDelete); break;
- case 'choiceStep':
- const otherwise = (step as ChoiceStep).choice.otherwise;
+ case 'policy': (step as Policy).steps = CamelApi.deleteStep((step as Policy).steps, uuidToDelete); break;
+ case 'choice':
+ const otherwise = (step as Choice).otherwise;
if (otherwise && otherwise.uuid === uuidToDelete) {
- (step as ChoiceStep).choice.otherwise = undefined;
+ (step as Choice).otherwise = undefined;
} else if (otherwise && otherwise.uuid !== uuidToDelete) {
otherwise.steps = CamelApi.deleteStep(otherwise.steps, uuidToDelete);
- (step as ChoiceStep).choice.otherwise = otherwise;
+ (step as Choice).otherwise = otherwise;
}
- (step as ChoiceStep).choice.when = CamelApi.deleteWhen((step as ChoiceStep).choice.when, uuidToDelete);
+ (step as Choice).when = CamelApi.deleteWhen((step as Choice).when, uuidToDelete);
break;
case 'otherwise': (step as Otherwise).steps = CamelApi.deleteStep((step as Otherwise).steps, uuidToDelete); break;
- case 'fromStep': (step as FromStep).from.steps = CamelApi.deleteStep((step as FromStep).from.steps, uuidToDelete); break;
- case 'onCompletionStep': (step as OnCompletionStep).onCompletion.steps = CamelApi.deleteStep((step as OnCompletionStep).onCompletion.steps, uuidToDelete); break;
- case 'splitStep': (step as SplitStep).split.steps = CamelApi.deleteStep((step as SplitStep).split.steps, uuidToDelete); break;
- case 'transactedStep': (step as TransactedStep).transacted.steps = CamelApi.deleteStep((step as TransactedStep).transacted.steps, uuidToDelete); break;
- case 'interceptFromStep': (step as InterceptFromStep).interceptFrom.steps = CamelApi.deleteStep((step as InterceptFromStep).interceptFrom.steps, uuidToDelete); break;
- case 'doCatchStep': (step as DoCatchStep).doCatch.steps = CamelApi.deleteStep((step as DoCatchStep).doCatch.steps, uuidToDelete); break;
- case 'circuitBreakerStep': (step as CircuitBreakerStep).circuitBreaker.steps = CamelApi.deleteStep((step as CircuitBreakerStep).circuitBreaker.steps, uuidToDelete); break;
- case 'interceptStep': (step as InterceptStep).intercept.steps = CamelApi.deleteStep((step as InterceptStep).intercept.steps, uuidToDelete); break;
- case 'onFallbackStep': (step as OnFallbackStep).onFallback.steps = CamelApi.deleteStep((step as OnFallbackStep).onFallback.steps, uuidToDelete); break;
- case 'multicastStep': (step as MulticastStep).multicast.steps = CamelApi.deleteStep((step as MulticastStep).multicast.steps, uuidToDelete); break;
- case 'loadBalanceStep': (step as LoadBalanceStep).loadBalance.steps = CamelApi.deleteStep((step as LoadBalanceStep).loadBalance.steps, uuidToDelete); break;
- case 'whenSkipSendToEndpointStep': (step as WhenSkipSendToEndpointStep).whenSkipSendToEndpoint.steps = CamelApi.deleteStep((step as WhenSkipSendToEndpointStep).whenSkipSendToEndpoint.steps, uuidToDelete); break;
- case 'loopStep': (step as LoopStep).loop.steps = CamelApi.deleteStep((step as LoopStep).loop.steps, uuidToDelete); break;
- case 'interceptSendToEndpointStep': (step as InterceptSendToEndpointStep).interceptSendToEndpoint.steps = CamelApi.deleteStep((step as InterceptSendToEndpointStep).interceptSendToEndpoint.steps, uuidToDelete); break;
- case 'doTryStep': (step as DoTryStep).doTry.steps = CamelApi.deleteStep((step as DoTryStep).doTry.steps, uuidToDelete); break;
- case 'resequenceStep': (step as ResequenceStep).resequence.steps = CamelApi.deleteStep((step as ResequenceStep).resequence.steps, uuidToDelete); break;
- case 'pipelineStep': (step as PipelineStep).pipeline.steps = CamelApi.deleteStep((step as PipelineStep).pipeline.steps, uuidToDelete); break;
- case 'sagaStep': (step as SagaStep).saga.steps = CamelApi.deleteStep((step as SagaStep).saga.steps, uuidToDelete); break;
+ case 'from': (step as From).steps = CamelApi.deleteStep((step as From).steps, uuidToDelete); break;
+ case 'onCompletion': (step as OnCompletion).steps = CamelApi.deleteStep((step as OnCompletion).steps, uuidToDelete); break;
+ case 'split': (step as Split).steps = CamelApi.deleteStep((step as Split).steps, uuidToDelete); break;
+ case 'transacted': (step as Transacted).steps = CamelApi.deleteStep((step as Transacted).steps, uuidToDelete); break;
+ case 'interceptFrom': (step as InterceptFrom).steps = CamelApi.deleteStep((step as InterceptFrom).steps, uuidToDelete); break;
+ case 'doCatch': (step as DoCatch).steps = CamelApi.deleteStep((step as DoCatch).steps, uuidToDelete); break;
+ case 'circuitBreaker': (step as CircuitBreaker).steps = CamelApi.deleteStep((step as CircuitBreaker).steps, uuidToDelete); break;
+ case 'intercept': (step as Intercept).steps = CamelApi.deleteStep((step as Intercept).steps, uuidToDelete); break;
+ case 'onFallback': (step as OnFallback).steps = CamelApi.deleteStep((step as OnFallback).steps, uuidToDelete); break;
+ case 'multicast': (step as Multicast).steps = CamelApi.deleteStep((step as Multicast).steps, uuidToDelete); break;
+ case 'loadBalance': (step as LoadBalance).steps = CamelApi.deleteStep((step as LoadBalance).steps, uuidToDelete); break;
+ case 'whenSkipSendToEndpoint': (step as WhenSkipSendToEndpoint).steps = CamelApi.deleteStep((step as WhenSkipSendToEndpoint).steps, uuidToDelete); break;
+ case 'loop': (step as Loop).steps = CamelApi.deleteStep((step as Loop).steps, uuidToDelete); break;
+ case 'interceptSendToEndpoint': (step as InterceptSendToEndpoint).steps = CamelApi.deleteStep((step as InterceptSendToEndpoint).steps, uuidToDelete); break;
+ case 'doTry': (step as DoTry).steps = CamelApi.deleteStep((step as DoTry).steps, uuidToDelete); break;
+ case 'resequence': (step as Resequence).steps = CamelApi.deleteStep((step as Resequence).steps, uuidToDelete); break;
+ case 'pipeline': (step as Pipeline).steps = CamelApi.deleteStep((step as Pipeline).steps, uuidToDelete); break;
+ case 'saga': (step as Saga).steps = CamelApi.deleteStep((step as Saga).steps, uuidToDelete); break;
case 'when': (step as When).steps = CamelApi.deleteStep((step as When).steps, uuidToDelete); break;
- case 'doFinallyStep': (step as DoFinallyStep).doFinally.steps = CamelApi.deleteStep((step as DoFinallyStep).doFinally.steps, uuidToDelete); break;
- case 'filterStep': (step as FilterStep).filter.steps = CamelApi.deleteStep((step as FilterStep).filter.steps, uuidToDelete); break;
- case 'aggregateStep': (step as AggregateStep).aggregate.steps = CamelApi.deleteStep((step as AggregateStep).aggregate.steps, uuidToDelete); break;
- case 'idempotentConsumerStep': (step as IdempotentConsumerStep).idempotentConsumer.steps = CamelApi.deleteStep((step as IdempotentConsumerStep).idempotentConsumer.steps, uuidToDelete); break;
+ case 'doFinally': (step as DoFinally).steps = CamelApi.deleteStep((step as DoFinally).steps, uuidToDelete); break;
+ case 'filter': (step as Filter).steps = CamelApi.deleteStep((step as Filter).steps, uuidToDelete); break;
+ case 'aggregate': (step as Aggregate).steps = CamelApi.deleteStep((step as Aggregate).steps, uuidToDelete); break;
+ case 'idempotentConsumer': (step as IdempotentConsumer).steps = CamelApi.deleteStep((step as IdempotentConsumer).steps, uuidToDelete); break;
}
result.push(step);
}
@@ -1141,21 +1039,21 @@ export class CamelApi {
return result
}
- static findStep = (steps: ProcessorStep[] | undefined, uuid: string, parentUuid?: string, result?: ProcessorStepMeta): ProcessorStepMeta => {
+ static findStep = (steps: CamelElement[] | undefined, uuid: string, parentUuid?: string, result?: CamelElementMeta): CamelElementMeta => {
if (result?.step !== undefined) return result;
- if (result === undefined) result = new ProcessorStepMeta(undefined, parentUuid, undefined, []);
+ if (result === undefined) result = new CamelElementMeta(undefined, parentUuid, undefined, []);
if (steps !== undefined){
for (let index = 0, step; step = steps[index]; index++) {
if (step.uuid !== uuid) {
switch (step.dslName) {
- case 'policyStep':
- result = CamelApi.findStep((step as PolicyStep).policy.steps, uuid, step.uuid, result);
+ case 'policy':
+ result = CamelApi.findStep((step as Policy).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'choiceStep':
- const o = (step as ChoiceStep).choice.otherwise;
- const w = (step as ChoiceStep).choice.when;
- const s: ProcessorStep[] = [];
+ case 'choice':
+ const o = (step as Choice).otherwise;
+ const w = (step as Choice).when;
+ const s: CamelElement[] = [];
if (o) s.push(o);
if (w) s.push(...w);
result = CamelApi.findStep(s, uuid, step.uuid, result);
@@ -1165,109 +1063,109 @@ export class CamelApi {
result = CamelApi.findStep((step as Otherwise).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'fromStep':
- result = CamelApi.findStep((step as FromStep).from.steps, uuid, step.uuid, result);
+ case 'from':
+ result = CamelApi.findStep((step as From).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'onCompletionStep':
- result = CamelApi.findStep((step as OnCompletionStep).onCompletion.steps, uuid, step.uuid, result);
+ case 'onCompletion':
+ result = CamelApi.findStep((step as OnCompletion).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'splitStep':
- result = CamelApi.findStep((step as SplitStep).split.steps, uuid, step.uuid, result);
+ case 'split':
+ result = CamelApi.findStep((step as Split).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'transactedStep':
- result = CamelApi.findStep((step as TransactedStep).transacted.steps, uuid, step.uuid, result);
+ case 'transacted':
+ result = CamelApi.findStep((step as Transacted).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'interceptFromStep':
- result = CamelApi.findStep((step as InterceptFromStep).interceptFrom.steps, uuid, step.uuid, result);
+ case 'interceptFrom':
+ result = CamelApi.findStep((step as InterceptFrom).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'doCatchStep':
- result = CamelApi.findStep((step as DoCatchStep).doCatch.steps, uuid, step.uuid, result);
+ case 'doCatch':
+ result = CamelApi.findStep((step as DoCatch).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'circuitBreakerStep':
- result = CamelApi.findStep((step as CircuitBreakerStep).circuitBreaker.steps, uuid, step.uuid, result);
+ case 'circuitBreaker':
+ result = CamelApi.findStep((step as CircuitBreaker).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'interceptStep':
- result = CamelApi.findStep((step as InterceptStep).intercept.steps, uuid, step.uuid, result);
+ case 'intercept':
+ result = CamelApi.findStep((step as Intercept).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'onFallbackStep':
- result = CamelApi.findStep((step as OnFallbackStep).onFallback.steps, uuid, step.uuid, result);
+ case 'onFallback':
+ result = CamelApi.findStep((step as OnFallback).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'multicastStep':
- result = CamelApi.findStep((step as MulticastStep).multicast.steps, uuid, step.uuid, result);
+ case 'multicast':
+ result = CamelApi.findStep((step as Multicast).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'loadBalanceStep':
- result = CamelApi.findStep((step as LoadBalanceStep).loadBalance.steps, uuid, step.uuid, result);
+ case 'loadBalance':
+ result = CamelApi.findStep((step as LoadBalance).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'whenSkipSendToEndpointStep':
- result = CamelApi.findStep((step as WhenSkipSendToEndpointStep).whenSkipSendToEndpoint.steps, uuid, step.uuid, result);
+ case 'whenSkipSendToEndpoint':
+ result = CamelApi.findStep((step as WhenSkipSendToEndpoint).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'loopStep':
- result = CamelApi.findStep((step as LoopStep).loop.steps, uuid, step.uuid, result);
+ case 'loop':
+ result = CamelApi.findStep((step as Loop).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'interceptSendToEndpointStep':
- result = CamelApi.findStep((step as InterceptSendToEndpointStep).interceptSendToEndpoint.steps, uuid, step.uuid, result);
+ case 'interceptSendToEndpoint':
+ result = CamelApi.findStep((step as InterceptSendToEndpoint).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'doTryStep':
- result = CamelApi.findStep((step as DoTryStep).doTry.steps, uuid, step.uuid, result);
+ case 'doTry':
+ result = CamelApi.findStep((step as DoTry).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'resequenceStep':
- result = CamelApi.findStep((step as ResequenceStep).resequence.steps, uuid, step.uuid, result);
+ case 'resequence':
+ result = CamelApi.findStep((step as Resequence).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'pipelineStep':
- result = CamelApi.findStep((step as PipelineStep).pipeline.steps, uuid, step.uuid, result);
+ case 'pipeline':
+ result = CamelApi.findStep((step as Pipeline).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'sagaStep':
- result = CamelApi.findStep((step as SagaStep).saga.steps, uuid, step.uuid, result);
+ case 'saga':
+ result = CamelApi.findStep((step as Saga).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
case 'when':
result = CamelApi.findStep((step as When).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'doFinallyStep':
- result = CamelApi.findStep((step as DoFinallyStep).doFinally.steps, uuid, step.uuid, result);
+ case 'doFinally':
+ result = CamelApi.findStep((step as DoFinally).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'filterStep':
- result = CamelApi.findStep((step as FilterStep).filter.steps, uuid, step.uuid, result);
+ case 'filter':
+ result = CamelApi.findStep((step as Filter).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'aggregateStep':
- result = CamelApi.findStep((step as AggregateStep).aggregate.steps, uuid, step.uuid, result);
+ case 'aggregate':
+ result = CamelApi.findStep((step as Aggregate).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
- case 'idempotentConsumerStep':
- result = CamelApi.findStep((step as IdempotentConsumerStep).idempotentConsumer.steps, uuid, step.uuid, result);
+ case 'idempotentConsumer':
+ result = CamelApi.findStep((step as IdempotentConsumer).steps, uuid, step.uuid, result);
if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);
break;
}
} else {
const paths: string[] = result?.pathUuids ? result?.pathUuids : [];
paths.push(step.uuid);
- result = new ProcessorStepMeta(step, parentUuid, index, paths);
+ result = new CamelElementMeta(step, parentUuid, index, paths);
break;
}
}
}
const paths: string[] = result?.pathUuids ? result?.pathUuids : [];
- return new ProcessorStepMeta(result?.step, result?.parentUuid, result?.position, result?.pathUuids);
+ return new CamelElementMeta(result?.step, result?.parentUuid, result?.position, result?.pathUuids);
}
static getExpressionLanguage = (init?: Partial<Expression>): string | undefined => {
diff --git a/karavan-core/src/core/api/CamelApiExt.ts b/karavan-core/src/core/api/CamelApiExt.ts
index 5c1eec7..4cd6250 100644
--- a/karavan-core/src/core/api/CamelApiExt.ts
+++ b/karavan-core/src/core/api/CamelApiExt.ts
@@ -14,20 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {CamelElement, Expression, FromStep, Integration, ProcessorStep} from "../model/CamelModel";
+import {CamelElement, Expression, From, Integration} from "../model/CamelModel";
import {CamelMetadataApi, DataFormats, PropertyMeta} from "./CamelMetadata";
import {CamelApi} from "./CamelApi";
import {ComponentApi} from "./ComponentApi";
import {DataFormat} from "../model/CamelDataFormat";
+import {CamelUtil} from "./CamelUtil";
export class CamelApiExt {
static addStepToIntegration = (integration: Integration, step: CamelElement, parentId: string, position?: number): Integration => {
- if (step.dslName === 'fromStep') {
- integration.spec.flows.push(step as FromStep);
+ if (step.dslName === 'from') {
+ integration.spec.flows.push(step as From);
} else {
const flows = CamelApi.addStep(integration.spec.flows, step, parentId, position);
- integration.spec.flows = flows as FromStep[];
+ integration.spec.flows = flows as From[];
}
return integration;
}
@@ -59,7 +60,7 @@ export class CamelApiExt {
static deleteStepFromIntegration = (integration: Integration, uuidToDelete: string): Integration => {
const flows = CamelApi.deleteStep(integration.spec.flows, uuidToDelete);
- integration.spec.flows = flows as FromStep[];
+ integration.spec.flows = flows as From[];
return integration;
}
@@ -88,8 +89,9 @@ export class CamelApiExt {
}
static updateIntegration = (integration: Integration, e: CamelElement, updatedUuid: string): Integration => {
- const int: Integration = new Integration({...integration});
- const flows = integration.spec.flows.map(f => CamelApiExt.updateElement(f, e) as FromStep)
+ const elementClone = CamelUtil.cloneStep(e);
+ const int: Integration = CamelUtil.cloneIntegration(integration);
+ const flows = integration.spec.flows.map(f => CamelApiExt.updateElement(f, elementClone) as From)
const flows2 = flows.map(f => CamelApi.createFrom(f));
int.spec.flows = flows2
return int;
@@ -166,16 +168,16 @@ export class CamelApiExt {
static getToStepsFromIntegration = (integration: Integration): [CamelElement, number][] => {
const result: [CamelElement, number][] = [];
- integration.spec.flows.forEach((flow, index) => {
- const steps: [CamelElement, number][] = CamelApiExt.getOutgoingStepsFromStep(flow.from, 0);
+ integration.spec.flows.forEach((from, index) => {
+ const steps: [CamelElement, number][] = CamelApiExt.getOutgoingStepsFromStep(from, 0);
result.push(...steps);
})
return result;
}
- static getOutgoingStepsFromStep = (step: ProcessorStep, level: number): [CamelElement, number][] => {
+ static getOutgoingStepsFromStep = (step: CamelElement, level: number): [CamelElement, number][] => {
const result: [CamelElement, number][] = [];
- if (['toStep', 'kameletStep'].includes(step.dslName)) result.push([step, level]);
+ if (['to', 'kamelet'].includes(step.dslName)) result.push([step, level]);
const element: any = Object.assign({}, step);
Object.keys(element).forEach(key => {
if (element[key] instanceof CamelElement) {
diff --git a/karavan-core/src/core/api/CamelUi.ts b/karavan-core/src/core/api/CamelUi.ts
index 6d6be18..ff36d13 100644
--- a/karavan-core/src/core/api/CamelUi.ts
+++ b/karavan-core/src/core/api/CamelUi.ts
@@ -24,6 +24,7 @@ import {CamelApiExt} from "./CamelApiExt";
import {CamelApi} from "./CamelApi";
import {Kamelet} from "../model/CamelModel";
import {CamelModelMetadata} from "./CamelMetadata";
+import {CamelUtil} from "./CamelUtil";
const DslElements: string[] = [
"aggregate",
@@ -172,7 +173,7 @@ export class CamelUi {
? name
.replace(".yaml", "")
.split("-")
- .map((value) => CamelApi.capitalizeName(value))
+ .map((value) => CamelUtil.capitalizeName(value))
.reduce(
(previousValue, currentValue) => previousValue + " " + currentValue
)
@@ -234,8 +235,8 @@ export class CamelUi {
return k.title();
} else {
return uri
- ? CamelApi.capitalizeName(element.dslName) + " : " + ComponentApi.getComponentNameFromUri(uri)
- : CamelApi.capitalizeName(element.dslName);
+ ? CamelUtil.capitalizeName(element.dslName) + " : " + ComponentApi.getComponentNameFromUri(uri)
+ : CamelUtil.capitalizeName(element.dslName);
}
};
diff --git a/karavan-core/src/core/api/CamelUtil.ts b/karavan-core/src/core/api/CamelUtil.ts
new file mode 100644
index 0000000..c473dc7
--- /dev/null
+++ b/karavan-core/src/core/api/CamelUtil.ts
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as yaml from 'js-yaml';
+import {
+ Integration,
+ CamelElement,
+} from "../model/CamelModel";
+import {CamelApi} from "./CamelApi";
+
+
+export class CamelUtil {
+
+ static cloneIntegration = (integration: Integration): Integration => {
+ const clone = JSON.parse(JSON.stringify(integration));
+ const int: Integration = new Integration({...clone});
+ const flows = int.spec.flows.map(f => CamelApi.createFrom(f))
+ int.spec.flows = flows;
+ return int;
+ }
+
+ static cloneStep = (step: CamelElement): CamelElement => {
+ const clone = JSON.parse(JSON.stringify(step));
+ return CamelApi.createStep(step.dslName, clone, true);
+ }
+
+ static replacer = (key:string, value:any): any=> {
+ if (typeof value == 'object' && (value.hasOwnProperty('dslName') || value.hasOwnProperty('dsl-name'))) {
+ const dslNameField = value.hasOwnProperty('dslName') ? 'dslName' : 'dsl-name';
+ const dslName = value[dslNameField];
+ const x = JSON.parse(JSON.stringify(value));
+ delete x[dslNameField];
+ if (['when', 'otherwise', 'expression'].includes(value[dslNameField])){
+ return x;
+ } else {
+ const newValue: any = {};
+ newValue[dslName] = x;
+ return newValue;
+ }
+ } else {
+ return value;
+ }
+ }
+
+ static capitalizeName = (name: string) => {
+ try {
+ return name[0].toUpperCase() + name.substring(1);
+ } catch (e) {
+ return name;
+ }
+ };
+
+ static camelizeName = (
+ name: string,
+ separator: string,
+ firstSmall: boolean
+ ) => {
+ const res = name
+ .split(separator)
+ .map((value) => CamelUtil.capitalizeName(value))
+ .join("");
+ return firstSmall ? res[0].toLowerCase() + res.substring(1) : res;
+ };
+
+ static camelizeBody = (name: string, body: any, clone: boolean): any => {
+ if (body){
+ const oldKey = Object.keys(body)[0];
+ const key = CamelUtil.camelizeName(oldKey, '-', true);
+ return !clone && key === name ? {[key]: body[oldKey]} : body;
+ } else {
+ return {};
+ }
+ };
+}
diff --git a/karavan-core/src/core/api/CamelYaml.ts b/karavan-core/src/core/api/CamelYaml.ts
index 333403d..7b83230 100644
--- a/karavan-core/src/core/api/CamelYaml.ts
+++ b/karavan-core/src/core/api/CamelYaml.ts
@@ -19,7 +19,8 @@ import {
Integration,
CamelElement,
} from "../model/CamelModel";
-import {CamelApi} from "./CamelApi";
+import {CamelUtil} from "./CamelUtil";
+import {CamelYamlStep} from "./CamelYamlSteps";
const saveKebabCase = true; //TODO: Remove when https://issues.apache.org/jira/browse/CAMEL-17097 fixed
@@ -30,13 +31,13 @@ export class CamelYaml {
const flows = integration.spec.flows
clone.spec.flows = flows.map((f: any) => CamelYaml.cleanupElement(f));
if (integration.crd) {
- delete clone.crd
+ delete clone.crd
const i = JSON.parse(JSON.stringify(clone, null, 3)); // fix undefined in string attributes
- const text = yaml.dump(i);
+ const text = CamelYaml.yamlDump(i);
return text;
} else {
const f = JSON.parse(JSON.stringify(clone.spec.flows, null, 3));
- const text = yaml.dump(f);
+ const text = CamelYaml.yamlDump(f);
return text;
}
}
@@ -48,7 +49,6 @@ export class CamelYaml {
delete object.language
}
delete object.uuid
- delete object.dslName
Object.keys(object)
.sort((a, b) => {
if (a === 'uri') return -1
@@ -63,7 +63,7 @@ export class CamelYaml {
if (object[key].length > 0) result[rkey] = CamelYaml.cleanupElements(object[key])
} else if (key === 'parameters' && typeof (object[key]) === 'object') {
const obj = object[key];
- const parameters = Object.keys(obj || {}).reduce((x:any, k) => {
+ const parameters = Object.keys(obj || {}).reduce((x: any, k) => {
// Check for null or undefined or empty
if (obj[k] !== null && obj[k] !== undefined && obj[k].toString().trim().length > 0) {
x[k] = obj[k];
@@ -87,6 +87,23 @@ export class CamelYaml {
return result
}
+ static yamlDump = (integration: Integration): string => {
+ return yaml.dump(integration,
+ {
+ noRefs: false,
+ noArrayIndent: false,
+ sortKeys: function (a:any, b:any) {
+ if (a === 'uri') return -1
+ else if (b === 'uri') return 0
+ else if (a === 'steps' && b !== 'uri') return -1
+ else if (b === 'steps' && a !== 'uri') return -1
+ else if (a > b) return 1
+ else return 0;
+ },
+ replacer: CamelUtil.replacer
+ });
+ }
+
static yamlToIntegration = (filename: string, text: string): Integration => {
const i: Integration = Integration.createNew(filename);
const fromYaml: any = yaml.load(text);
@@ -95,27 +112,13 @@ export class CamelYaml {
const flows: any[] = fromYaml;
const froms = flows.filter((e: any) => e.hasOwnProperty('from'));
if (froms.length > 0) {
- froms.forEach((f: any) => i.spec.flows.push(CamelApi.createFrom(f)));
+ froms.forEach((f: any) => i.spec.flows.push(CamelYamlStep.readFrom(f)));
}
} else {
i.crd = true;
const int: Integration = new Integration({...fromYaml});
- int.spec.flows.forEach((f: any) => i.spec.flows.push(CamelApi.createFrom(f)));
+ int.spec.flows.forEach((f: any) => i.spec.flows.push(CamelYamlStep.readFrom(f)));
}
return i;
}
-
- static cloneIntegration = (integration: Integration): Integration => {
- const clone = JSON.parse(JSON.stringify(integration));
- const int: Integration = new Integration({...clone});
- const flows = int.spec.flows.map(f => CamelApi.createFrom(f))
- int.spec.flows = flows;
- return int;
- }
-
- static cloneStep = (step: CamelElement): CamelElement => {
- const dslName = step.dslName.replace("Step", "");
- const clone = JSON.parse(JSON.stringify(step));
- return CamelApi.createStep(dslName, clone, true);
- }
}
diff --git a/karavan-core/src/core/api/CamelYamlSteps.ts b/karavan-core/src/core/api/CamelYamlSteps.ts
new file mode 100644
index 0000000..c4dd4c8
--- /dev/null
+++ b/karavan-core/src/core/api/CamelYamlSteps.ts
@@ -0,0 +1,848 @@
+/**
+ * Generated by karavan build tools - do NOT edit this file!
+ */
+import {
+ CamelElement,
+ From,
+ Expression,
+ Policy,
+ SetProperty,
+ Saga,
+ ToD,
+ Threads,
+ InterceptSendToEndpoint,
+ Log,
+ Loop,
+ Delay,
+ Sample,
+ DoFinally,
+ LoadBalance,
+ Validate,
+ Transform,
+ RemoveHeaders,
+ IdempotentConsumer,
+ Intercept,
+ When,
+ Process,
+ OnFallback,
+ Marshal,
+ OnCompletion,
+ ClaimCheck,
+ DoCatch,
+ InOnly,
+ ConvertBodyTo,
+ CircuitBreaker,
+ PollEnrich,
+ Otherwise,
+ Resequence,
+ RoutingSlip,
+ Bean,
+ RecipientList,
+ Kamelet,
+ DynamicRouter,
+ Rollback,
+ InOut,
+ Enrich,
+ Split,
+ WireTap,
+ Multicast,
+ Stop,
+ SetBody,
+ Sort,
+ InterceptFrom,
+ ThrowException,
+ To,
+ Filter,
+ ServiceCall,
+ Throttle,
+ WhenSkipSendToEndpoint,
+ RemoveProperties,
+ SetHeader,
+ Choice,
+ Aggregate,
+ RemoveProperty,
+ RemoveHeader,
+ Script,
+ DoTry,
+ SetExchangePattern,
+ Transacted,
+ Pipeline,
+ Unmarshal,
+} from '../model/CamelModel'
+import * as dataFormat from '../model/CamelDataFormat';
+import {CamelUtil} from "./CamelUtil";
+
+export class CamelYamlStep {
+
+ static readStep = (name: string, body: any, clone: boolean = false): CamelElement => {
+ const newBody = CamelUtil.camelizeBody(name, body, clone);
+ switch (name){
+ case 'from': return CamelYamlStep.readFrom(newBody);
+ case 'expression': return CamelYamlStep.readExpression(newBody);
+ case 'policy': return CamelYamlStep.readPolicy(newBody);
+ case 'setProperty': return CamelYamlStep.readSetProperty(newBody);
+ case 'saga': return CamelYamlStep.readSaga(newBody);
+ case 'toD': return CamelYamlStep.readToD(newBody);
+ case 'threads': return CamelYamlStep.readThreads(newBody);
+ case 'interceptSendToEndpoint': return CamelYamlStep.readInterceptSendToEndpoint(newBody);
+ case 'log': return CamelYamlStep.readLog(newBody);
+ case 'loop': return CamelYamlStep.readLoop(newBody);
+ case 'delay': return CamelYamlStep.readDelay(newBody);
+ case 'sample': return CamelYamlStep.readSample(newBody);
+ case 'doFinally': return CamelYamlStep.readDoFinally(newBody);
+ case 'loadBalance': return CamelYamlStep.readLoadBalance(newBody);
+ case 'validate': return CamelYamlStep.readValidate(newBody);
+ case 'transform': return CamelYamlStep.readTransform(newBody);
+ case 'removeHeaders': return CamelYamlStep.readRemoveHeaders(newBody);
+ case 'idempotentConsumer': return CamelYamlStep.readIdempotentConsumer(newBody);
+ case 'intercept': return CamelYamlStep.readIntercept(newBody);
+ case 'when': return CamelYamlStep.readWhen(newBody);
+ case 'process': return CamelYamlStep.readProcess(newBody);
+ case 'onFallback': return CamelYamlStep.readOnFallback(newBody);
+ case 'marshal': return CamelYamlStep.readMarshal(newBody);
+ case 'onCompletion': return CamelYamlStep.readOnCompletion(newBody);
+ case 'claimCheck': return CamelYamlStep.readClaimCheck(newBody);
+ case 'doCatch': return CamelYamlStep.readDoCatch(newBody);
+ case 'inOnly': return CamelYamlStep.readInOnly(newBody);
+ case 'convertBodyTo': return CamelYamlStep.readConvertBodyTo(newBody);
+ case 'circuitBreaker': return CamelYamlStep.readCircuitBreaker(newBody);
+ case 'pollEnrich': return CamelYamlStep.readPollEnrich(newBody);
+ case 'otherwise': return CamelYamlStep.readOtherwise(newBody);
+ case 'resequence': return CamelYamlStep.readResequence(newBody);
+ case 'routingSlip': return CamelYamlStep.readRoutingSlip(newBody);
+ case 'bean': return CamelYamlStep.readBean(newBody);
+ case 'recipientList': return CamelYamlStep.readRecipientList(newBody);
+ case 'kamelet': return CamelYamlStep.readKamelet(newBody);
+ case 'dynamicRouter': return CamelYamlStep.readDynamicRouter(newBody);
+ case 'rollback': return CamelYamlStep.readRollback(newBody);
+ case 'inOut': return CamelYamlStep.readInOut(newBody);
+ case 'enrich': return CamelYamlStep.readEnrich(newBody);
+ case 'split': return CamelYamlStep.readSplit(newBody);
+ case 'wireTap': return CamelYamlStep.readWireTap(newBody);
+ case 'multicast': return CamelYamlStep.readMulticast(newBody);
+ case 'stop': return CamelYamlStep.readStop(newBody);
+ case 'setBody': return CamelYamlStep.readSetBody(newBody);
+ case 'sort': return CamelYamlStep.readSort(newBody);
+ case 'interceptFrom': return CamelYamlStep.readInterceptFrom(newBody);
+ case 'throwException': return CamelYamlStep.readThrowException(newBody);
+ case 'to': return CamelYamlStep.readTo(newBody);
+ case 'filter': return CamelYamlStep.readFilter(newBody);
+ case 'serviceCall': return CamelYamlStep.readServiceCall(newBody);
+ case 'throttle': return CamelYamlStep.readThrottle(newBody);
+ case 'whenSkipSendToEndpoint': return CamelYamlStep.readWhenSkipSendToEndpoint(newBody);
+ case 'removeProperties': return CamelYamlStep.readRemoveProperties(newBody);
+ case 'setHeader': return CamelYamlStep.readSetHeader(newBody);
+ case 'choice': return CamelYamlStep.readChoice(newBody);
+ case 'aggregate': return CamelYamlStep.readAggregate(newBody);
+ case 'removeProperty': return CamelYamlStep.readRemoveProperty(newBody);
+ case 'removeHeader': return CamelYamlStep.readRemoveHeader(newBody);
+ case 'script': return CamelYamlStep.readScript(newBody);
+ case 'doTry': return CamelYamlStep.readDoTry(newBody);
+ case 'setExchangePattern': return CamelYamlStep.readSetExchangePattern(newBody);
+ case 'transacted': return CamelYamlStep.readTransacted(newBody);
+ case 'pipeline': return CamelYamlStep.readPipeline(newBody);
+ case 'unmarshal': return CamelYamlStep.readUnmarshal(newBody);
+ default: return new CamelElement('');
+ }
+ }
+ static readExpression = (element: any): Expression => {
+ return new Expression({...element})
+ }
+ static readFrom = (element: any): From => {
+ if (element && element.from && typeof element.from === 'string') element.from = {uri: element.from};
+ const from = element ? new From({...element.from}) : new From();
+ from.steps = CamelYamlStep.readSteps(element?.from?.steps);
+ from.uuid = element?.uuid ? element.uuid : from.uuid;
+ return from;
+ }
+
+ static readPolicy = (element: any): Policy => {
+ const policy = element ? new Policy({...element.policy}) : new Policy();
+ policy.steps = CamelYamlStep.readSteps(element?.policy?.steps);
+ policy.uuid = element?.uuid ? element.uuid : policy.uuid;
+ return policy;
+ }
+
+ static readSetProperty = (element: any): SetProperty => {
+ const setProperty = element ? new SetProperty({...element.setProperty}) : new SetProperty();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.setProperty);
+ if (implicitExpression){
+ setProperty.expression = new Expression({[implicitExpression]: element.setProperty[implicitExpression]});
+ delete (setProperty as any)[implicitExpression];
+ } else {
+ setProperty.expression = CamelYamlStep.readExpression(element?.setProperty?.expression);
+ }
+ setProperty.uuid = element?.uuid ? element.uuid : setProperty.uuid;
+ return setProperty;
+ }
+
+ static readSaga = (element: any): Saga => {
+ const saga = element ? new Saga({...element.saga}) : new Saga();
+ saga.steps = CamelYamlStep.readSteps(element?.saga?.steps);
+ saga.uuid = element?.uuid ? element.uuid : saga.uuid;
+ return saga;
+ }
+
+ static readToD = (element: any): ToD => {
+ if (element && element.toD && typeof element.toD === 'string') element.toD = {uri: element.toD};
+ const toD = element ? new ToD({...element.toD}) : new ToD();
+ toD.uuid = element?.uuid ? element.uuid : toD.uuid;
+ return toD;
+ }
+
+ static readThreads = (element: any): Threads => {
+ const threads = element ? new Threads({...element.threads}) : new Threads();
+ threads.uuid = element?.uuid ? element.uuid : threads.uuid;
+ return threads;
+ }
+
+ static readInterceptSendToEndpoint = (element: any): InterceptSendToEndpoint => {
+ if (element && element.interceptSendToEndpoint && typeof element.interceptSendToEndpoint === 'string') element.interceptSendToEndpoint = {uri: element.interceptSendToEndpoint};
+ const interceptSendToEndpoint = element ? new InterceptSendToEndpoint({...element.interceptSendToEndpoint}) : new InterceptSendToEndpoint();
+ interceptSendToEndpoint.steps = CamelYamlStep.readSteps(element?.interceptSendToEndpoint?.steps);
+ interceptSendToEndpoint.uuid = element?.uuid ? element.uuid : interceptSendToEndpoint.uuid;
+ return interceptSendToEndpoint;
+ }
+
+ static readLog = (element: any): Log => {
+ if (element && element.log && typeof element.log === 'string') element.log = {message: element.log};
+ const log = element ? new Log({...element.log}) : new Log();
+ log.uuid = element?.uuid ? element.uuid : log.uuid;
+ return log;
+ }
+
+ static readLoop = (element: any): Loop => {
+ const loop = element ? new Loop({...element.loop}) : new Loop();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.loop);
+ if (implicitExpression){
+ loop.expression = new Expression({[implicitExpression]: element.loop[implicitExpression]});
+ delete (loop as any)[implicitExpression];
+ } else {
+ loop.expression = CamelYamlStep.readExpression(element?.loop?.expression);
+ }
+ loop.steps = CamelYamlStep.readSteps(element?.loop?.steps);
+ loop.uuid = element?.uuid ? element.uuid : loop.uuid;
+ return loop;
+ }
+
+ static readDelay = (element: any): Delay => {
+ const delay = element ? new Delay({...element.delay}) : new Delay();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.delay);
+ if (implicitExpression){
+ delay.expression = new Expression({[implicitExpression]: element.delay[implicitExpression]});
+ delete (delay as any)[implicitExpression];
+ } else {
+ delay.expression = CamelYamlStep.readExpression(element?.delay?.expression);
+ }
+ delay.uuid = element?.uuid ? element.uuid : delay.uuid;
+ return delay;
+ }
+
+ static readSample = (element: any): Sample => {
+ const sample = element ? new Sample({...element.sample}) : new Sample();
+ sample.uuid = element?.uuid ? element.uuid : sample.uuid;
+ return sample;
+ }
+
+ static readDoFinally = (element: any): DoFinally => {
+ const doFinally = element ? new DoFinally({...element.doFinally}) : new DoFinally();
+ doFinally.steps = CamelYamlStep.readSteps(element?.doFinally?.steps);
+ doFinally.uuid = element?.uuid ? element.uuid : doFinally.uuid;
+ return doFinally;
+ }
+
+ static readLoadBalance = (element: any): LoadBalance => {
+ const loadBalance = element ? new LoadBalance({...element.loadBalance}) : new LoadBalance();
+ loadBalance.steps = CamelYamlStep.readSteps(element?.loadBalance?.steps);
+ loadBalance.uuid = element?.uuid ? element.uuid : loadBalance.uuid;
+ return loadBalance;
+ }
+
+ static readValidate = (element: any): Validate => {
+ const validate = element ? new Validate({...element.validate}) : new Validate();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.validate);
+ if (implicitExpression){
+ validate.expression = new Expression({[implicitExpression]: element.validate[implicitExpression]});
+ delete (validate as any)[implicitExpression];
+ } else {
+ validate.expression = CamelYamlStep.readExpression(element?.validate?.expression);
+ }
+ validate.uuid = element?.uuid ? element.uuid : validate.uuid;
+ return validate;
+ }
+
+ static readTransform = (element: any): Transform => {
+ const transform = element ? new Transform({...element.transform}) : new Transform();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.transform);
+ if (implicitExpression){
+ transform.expression = new Expression({[implicitExpression]: element.transform[implicitExpression]});
+ delete (transform as any)[implicitExpression];
+ } else {
+ transform.expression = CamelYamlStep.readExpression(element?.transform?.expression);
+ }
+ transform.uuid = element?.uuid ? element.uuid : transform.uuid;
+ return transform;
+ }
+
+ static readRemoveHeaders = (element: any): RemoveHeaders => {
+ if (element && element.removeHeaders && typeof element.removeHeaders === 'string') element.removeHeaders = {pattern: element.removeHeaders};
+ const removeHeaders = element ? new RemoveHeaders({...element.removeHeaders}) : new RemoveHeaders();
+ removeHeaders.uuid = element?.uuid ? element.uuid : removeHeaders.uuid;
+ return removeHeaders;
+ }
+
+ static readIdempotentConsumer = (element: any): IdempotentConsumer => {
+ const idempotentConsumer = element ? new IdempotentConsumer({...element.idempotentConsumer}) : new IdempotentConsumer();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.idempotentConsumer);
+ if (implicitExpression){
+ idempotentConsumer.expression = new Expression({[implicitExpression]: element.idempotentConsumer[implicitExpression]});
+ delete (idempotentConsumer as any)[implicitExpression];
+ } else {
+ idempotentConsumer.expression = CamelYamlStep.readExpression(element?.idempotentConsumer?.expression);
+ }
+ idempotentConsumer.steps = CamelYamlStep.readSteps(element?.idempotentConsumer?.steps);
+ idempotentConsumer.uuid = element?.uuid ? element.uuid : idempotentConsumer.uuid;
+ return idempotentConsumer;
+ }
+
+ static readIntercept = (element: any): Intercept => {
+ const intercept = element ? new Intercept({...element.intercept}) : new Intercept();
+ intercept.steps = CamelYamlStep.readSteps(element?.intercept?.steps);
+ intercept.uuid = element?.uuid ? element.uuid : intercept.uuid;
+ return intercept;
+ }
+
+ static readWhen = (element: any): When => {
+ const when = element ? new When({...element}) : new When()
+ when.expression = CamelYamlStep.readExpression(element?.expression)
+ when.steps = CamelYamlStep.readSteps(element?.steps)
+ when.uuid = element?.uuid ? element.uuid : when.uuid
+ return when
+ }
+
+ static readProcess = (element: any): Process => {
+ const process = element ? new Process({...element.process}) : new Process();
+ process.uuid = element?.uuid ? element.uuid : process.uuid;
+ return process;
+ }
+
+ static readOnFallback = (element: any): OnFallback => {
+ const onFallback = element ? new OnFallback({...element.onFallback}) : new OnFallback();
+ onFallback.steps = CamelYamlStep.readSteps(element?.onFallback?.steps);
+ onFallback.uuid = element?.uuid ? element.uuid : onFallback.uuid;
+ return onFallback;
+ }
+
+ static readMarshal = (element: any): Marshal => {
+ const marshal = element ? new Marshal({...element.marshal}) : new Marshal();
+ if (element.marshal?.any23 !== undefined) marshal.any23 = new dataFormat.Any23DataFormat(element.marshal.any23);
+ if (element.marshal?.asn1 !== undefined) marshal.asn1 = new dataFormat.ASN1DataFormat(element.marshal.asn1);
+ if (element.marshal?.avro !== undefined) marshal.avro = new dataFormat.AvroDataFormat(element.marshal.avro);
+ if (element.marshal?.barcode !== undefined) marshal.barcode = new dataFormat.BarcodeDataFormat(element.marshal.barcode);
+ if (element.marshal?.base64 !== undefined) marshal.base64 = new dataFormat.Base64DataFormat(element.marshal.base64);
+ if (element.marshal?.beanio !== undefined) marshal.beanio = new dataFormat.BeanioDataFormat(element.marshal.beanio);
+ if (element.marshal?.bindy !== undefined) marshal.bindy = new dataFormat.BindyDataFormat(element.marshal.bindy);
+ if (element.marshal?.cbor !== undefined) marshal.cbor = new dataFormat.CBORDataFormat(element.marshal.cbor);
+ if (element.marshal?.crypto !== undefined) marshal.crypto = new dataFormat.CryptoDataFormat(element.marshal.crypto);
+ if (element.marshal?.csv !== undefined) marshal.csv = new dataFormat.CsvDataFormat(element.marshal.csv);
+ if (element.marshal?.custom !== undefined) marshal.custom = new dataFormat.CustomDataFormat(element.marshal.custom);
+ if (element.marshal?.fhirJson !== undefined) marshal.fhirJson = new dataFormat.FhirJsonDataFormat(element.marshal.fhirJson);
+ if (element.marshal?.fhirXml !== undefined) marshal.fhirXml = new dataFormat.FhirXmlDataFormat(element.marshal.fhirXml);
+ if (element.marshal?.flatpack !== undefined) marshal.flatpack = new dataFormat.FlatpackDataFormat(element.marshal.flatpack);
+ if (element.marshal?.grok !== undefined) marshal.grok = new dataFormat.GrokDataFormat(element.marshal.grok);
+ if (element.marshal?.gzip !== undefined) marshal.gzip = new dataFormat.GzipDataFormat(element.marshal.gzip);
+ if (element.marshal?.hl7 !== undefined) marshal.hl7 = new dataFormat.HL7DataFormat(element.marshal.hl7);
+ if (element.marshal?.ical !== undefined) marshal.ical = new dataFormat.IcalDataFormat(element.marshal.ical);
+ if (element.marshal?.jacksonxml !== undefined) marshal.jacksonxml = new dataFormat.JacksonXMLDataFormat(element.marshal.jacksonxml);
+ if (element.marshal?.jaxb !== undefined) marshal.jaxb = new dataFormat.JaxbDataFormat(element.marshal.jaxb);
+ if (element.marshal?.json !== undefined) marshal.json = new dataFormat.JsonDataFormat(element.marshal.json);
+ if (element.marshal?.jsonApi !== undefined) marshal.jsonApi = new dataFormat.JsonApiDataFormat(element.marshal.jsonApi);
+ if (element.marshal?.lzf !== undefined) marshal.lzf = new dataFormat.LZFDataFormat(element.marshal.lzf);
+ if (element.marshal?.mimeMultipart !== undefined) marshal.mimeMultipart = new dataFormat.MimeMultipartDataFormat(element.marshal.mimeMultipart);
+ if (element.marshal?.pgp !== undefined) marshal.pgp = new dataFormat.PGPDataFormat(element.marshal.pgp);
+ if (element.marshal?.protobuf !== undefined) marshal.protobuf = new dataFormat.ProtobufDataFormat(element.marshal.protobuf);
+ if (element.marshal?.rss !== undefined) marshal.rss = new dataFormat.RssDataFormat(element.marshal.rss);
+ if (element.marshal?.secureXml !== undefined) marshal.secureXml = new dataFormat.XMLSecurityDataFormat(element.marshal.secureXml);
+ if (element.marshal?.soapjaxb !== undefined) marshal.soapjaxb = new dataFormat.SoapJaxbDataFormat(element.marshal.soapjaxb);
+ if (element.marshal?.syslog !== undefined) marshal.syslog = new dataFormat.SyslogDataFormat(element.marshal.syslog);
+ if (element.marshal?.tarfile !== undefined) marshal.tarfile = new dataFormat.TarFileDataFormat(element.marshal.tarfile);
+ if (element.marshal?.thrift !== undefined) marshal.thrift = new dataFormat.ThriftDataFormat(element.marshal.thrift);
+ if (element.marshal?.tidyMarkup !== undefined) marshal.tidyMarkup = new dataFormat.TidyMarkupDataFormat(element.marshal.tidyMarkup);
+ if (element.marshal?.univocityCsv !== undefined) marshal.univocityCsv = new dataFormat.UniVocityCsvDataFormat(element.marshal.univocityCsv);
+ if (element.marshal?.univocityFixed !== undefined) marshal.univocityFixed = new dataFormat.UniVocityFixedWidthDataFormat(element.marshal.univocityFixed);
+ if (element.marshal?.univocityTsv !== undefined) marshal.univocityTsv = new dataFormat.UniVocityTsvDataFormat(element.marshal.univocityTsv);
+ if (element.marshal?.xmlrpc !== undefined) marshal.xmlrpc = new dataFormat.XmlRpcDataFormat(element.marshal.xmlrpc);
+ if (element.marshal?.xstream !== undefined) marshal.xstream = new dataFormat.XStreamDataFormat(element.marshal.xstream);
+ if (element.marshal?.yaml !== undefined) marshal.yaml = new dataFormat.YAMLDataFormat(element.marshal.yaml);
+ if (element.marshal?.zip !== undefined) marshal.zip = new dataFormat.ZipDeflaterDataFormat(element.marshal.zip);
+ if (element.marshal?.zipfile !== undefined) marshal.zipfile = new dataFormat.ZipFileDataFormat(element.marshal.zipfile);
+ marshal.uuid = element?.uuid ? element.uuid : marshal.uuid;
+ return marshal;
+ }
+
+ static readOnCompletion = (element: any): OnCompletion => {
+ const onCompletion = element ? new OnCompletion({...element.onCompletion}) : new OnCompletion();
+ onCompletion.onWhen = CamelYamlStep.readWhen(element?.onCompletion?.onWhen);
+ onCompletion.steps = CamelYamlStep.readSteps(element?.onCompletion?.steps);
+ onCompletion.uuid = element?.uuid ? element.uuid : onCompletion.uuid;
+ return onCompletion;
+ }
+
+ static readClaimCheck = (element: any): ClaimCheck => {
+ const claimCheck = element ? new ClaimCheck({...element.claimCheck}) : new ClaimCheck();
+ claimCheck.uuid = element?.uuid ? element.uuid : claimCheck.uuid;
+ return claimCheck;
+ }
+
+ static readDoCatch = (element: any): DoCatch => {
+ const doCatch = element ? new DoCatch({...element.doCatch}) : new DoCatch();
+ doCatch.onWhen = CamelYamlStep.readWhen(element?.doCatch?.onWhen);
+ doCatch.steps = CamelYamlStep.readSteps(element?.doCatch?.steps);
+ doCatch.uuid = element?.uuid ? element.uuid : doCatch.uuid;
+ return doCatch;
+ }
+
+ static readInOnly = (element: any): InOnly => {
+ if (element && element.inOnly && typeof element.inOnly === 'string') element.inOnly = {uri: element.inOnly};
+ const inOnly = element ? new InOnly({...element.inOnly}) : new InOnly();
+ inOnly.uuid = element?.uuid ? element.uuid : inOnly.uuid;
+ return inOnly;
+ }
+
+ static readConvertBodyTo = (element: any): ConvertBodyTo => {
+ if (element && element.convertBodyTo && typeof element.convertBodyTo === 'string') element.convertBodyTo = {type: element.convertBodyTo};
+ const convertBodyTo = element ? new ConvertBodyTo({...element.convertBodyTo}) : new ConvertBodyTo();
+ convertBodyTo.uuid = element?.uuid ? element.uuid : convertBodyTo.uuid;
+ return convertBodyTo;
+ }
+
+ static readCircuitBreaker = (element: any): CircuitBreaker => {
+ const circuitBreaker = element ? new CircuitBreaker({...element.circuitBreaker}) : new CircuitBreaker();
+ circuitBreaker.onFallback = CamelYamlStep.readOnFallback(element?.circuitBreaker?.onFallback);
+ circuitBreaker.steps = CamelYamlStep.readSteps(element?.circuitBreaker?.steps);
+ circuitBreaker.uuid = element?.uuid ? element.uuid : circuitBreaker.uuid;
+ return circuitBreaker;
+ }
+
+ static readPollEnrich = (element: any): PollEnrich => {
+ const pollEnrich = element ? new PollEnrich({...element.pollEnrich}) : new PollEnrich();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.pollEnrich);
+ if (implicitExpression){
+ pollEnrich.expression = new Expression({[implicitExpression]: element.pollEnrich[implicitExpression]});
+ delete (pollEnrich as any)[implicitExpression];
+ } else {
+ pollEnrich.expression = CamelYamlStep.readExpression(element?.pollEnrich?.expression);
+ }
+ pollEnrich.uuid = element?.uuid ? element.uuid : pollEnrich.uuid;
+ return pollEnrich;
+ }
+
+ static readOtherwise = (element: any): Otherwise => {
+ const otherwise = element ? new Otherwise({...element}) : new Otherwise();
+ otherwise.steps = CamelYamlStep.readSteps(element?.steps);
+ if (element?.uuid) otherwise.uuid = element?.uuid;
+ return otherwise
+ }
+
+ static readResequence = (element: any): Resequence => {
+ const resequence = element ? new Resequence({...element.resequence}) : new Resequence();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.resequence);
+ if (implicitExpression){
+ resequence.expression = new Expression({[implicitExpression]: element.resequence[implicitExpression]});
+ delete (resequence as any)[implicitExpression];
+ } else {
+ resequence.expression = CamelYamlStep.readExpression(element?.resequence?.expression);
+ }
+ resequence.steps = CamelYamlStep.readSteps(element?.resequence?.steps);
+ resequence.uuid = element?.uuid ? element.uuid : resequence.uuid;
+ return resequence;
+ }
+
+ static readRoutingSlip = (element: any): RoutingSlip => {
+ const routingSlip = element ? new RoutingSlip({...element.routingSlip}) : new RoutingSlip();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.routingSlip);
+ if (implicitExpression){
+ routingSlip.expression = new Expression({[implicitExpression]: element.routingSlip[implicitExpression]});
+ delete (routingSlip as any)[implicitExpression];
+ } else {
+ routingSlip.expression = CamelYamlStep.readExpression(element?.routingSlip?.expression);
+ }
+ routingSlip.uuid = element?.uuid ? element.uuid : routingSlip.uuid;
+ return routingSlip;
+ }
+
+ static readBean = (element: any): Bean => {
+ const bean = element ? new Bean({...element.bean}) : new Bean();
+ bean.uuid = element?.uuid ? element.uuid : bean.uuid;
+ return bean;
+ }
+
+ static readRecipientList = (element: any): RecipientList => {
+ const recipientList = element ? new RecipientList({...element.recipientList}) : new RecipientList();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.recipientList);
+ if (implicitExpression){
+ recipientList.expression = new Expression({[implicitExpression]: element.recipientList[implicitExpression]});
+ delete (recipientList as any)[implicitExpression];
+ } else {
+ recipientList.expression = CamelYamlStep.readExpression(element?.recipientList?.expression);
+ }
+ recipientList.uuid = element?.uuid ? element.uuid : recipientList.uuid;
+ return recipientList;
+ }
+
+ static readKamelet = (element: any): Kamelet => {
+ if (element && element.kamelet && typeof element.kamelet === 'string') element.kamelet = {name: element.kamelet};
+ const kamelet = element ? new Kamelet({...element.kamelet}) : new Kamelet();
+ kamelet.uuid = element?.uuid ? element.uuid : kamelet.uuid;
+ return kamelet;
+ }
+
+ static readDynamicRouter = (element: any): DynamicRouter => {
+ const dynamicRouter = element ? new DynamicRouter({...element.dynamicRouter}) : new DynamicRouter();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.dynamicRouter);
+ if (implicitExpression){
+ dynamicRouter.expression = new Expression({[implicitExpression]: element.dynamicRouter[implicitExpression]});
+ delete (dynamicRouter as any)[implicitExpression];
+ } else {
+ dynamicRouter.expression = CamelYamlStep.readExpression(element?.dynamicRouter?.expression);
+ }
+ dynamicRouter.uuid = element?.uuid ? element.uuid : dynamicRouter.uuid;
+ return dynamicRouter;
+ }
+
+ static readRollback = (element: any): Rollback => {
+ const rollback = element ? new Rollback({...element.rollback}) : new Rollback();
+ rollback.uuid = element?.uuid ? element.uuid : rollback.uuid;
+ return rollback;
+ }
+
+ static readInOut = (element: any): InOut => {
+ if (element && element.inOut && typeof element.inOut === 'string') element.inOut = {uri: element.inOut};
+ const inOut = element ? new InOut({...element.inOut}) : new InOut();
+ inOut.uuid = element?.uuid ? element.uuid : inOut.uuid;
+ return inOut;
+ }
+
+ static readEnrich = (element: any): Enrich => {
+ const enrich = element ? new Enrich({...element.enrich}) : new Enrich();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.enrich);
+ if (implicitExpression){
+ enrich.expression = new Expression({[implicitExpression]: element.enrich[implicitExpression]});
+ delete (enrich as any)[implicitExpression];
+ } else {
+ enrich.expression = CamelYamlStep.readExpression(element?.enrich?.expression);
+ }
+ enrich.uuid = element?.uuid ? element.uuid : enrich.uuid;
+ return enrich;
+ }
+
+ static readSplit = (element: any): Split => {
+ const split = element ? new Split({...element.split}) : new Split();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.split);
+ if (implicitExpression){
+ split.expression = new Expression({[implicitExpression]: element.split[implicitExpression]});
+ delete (split as any)[implicitExpression];
+ } else {
+ split.expression = CamelYamlStep.readExpression(element?.split?.expression);
+ }
+ split.steps = CamelYamlStep.readSteps(element?.split?.steps);
+ split.uuid = element?.uuid ? element.uuid : split.uuid;
+ return split;
+ }
+
+ static readWireTap = (element: any): WireTap => {
+ const wireTap = element ? new WireTap({...element.wireTap}) : new WireTap();
+ wireTap.body = CamelYamlStep.readExpression(element?.wireTap?.body);
+ wireTap.setHeader = element && element?.wireTap ? element?.wireTap?.setHeader.map((x:any) => CamelYamlStep.readSetHeader(x)) :[];
+ wireTap.uuid = element?.uuid ? element.uuid : wireTap.uuid;
+ return wireTap;
+ }
+
+ static readMulticast = (element: any): Multicast => {
+ const multicast = element ? new Multicast({...element.multicast}) : new Multicast();
+ multicast.steps = CamelYamlStep.readSteps(element?.multicast?.steps);
+ multicast.uuid = element?.uuid ? element.uuid : multicast.uuid;
+ return multicast;
+ }
+
+ static readStop = (element: any): Stop => {
+ const stop = element ? new Stop({...element.stop}) : new Stop();
+ stop.uuid = element?.uuid ? element.uuid : stop.uuid;
+ return stop;
+ }
+
+ static readSetBody = (element: any): SetBody => {
+ const setBody = element ? new SetBody({...element.setBody}) : new SetBody();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.setBody);
+ if (implicitExpression){
+ setBody.expression = new Expression({[implicitExpression]: element.setBody[implicitExpression]});
+ delete (setBody as any)[implicitExpression];
+ } else {
+ setBody.expression = CamelYamlStep.readExpression(element?.setBody?.expression);
+ }
+ setBody.uuid = element?.uuid ? element.uuid : setBody.uuid;
+ return setBody;
+ }
+
+ static readSort = (element: any): Sort => {
+ const sort = element ? new Sort({...element.sort}) : new Sort();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.sort);
+ if (implicitExpression){
+ sort.expression = new Expression({[implicitExpression]: element.sort[implicitExpression]});
+ delete (sort as any)[implicitExpression];
+ } else {
+ sort.expression = CamelYamlStep.readExpression(element?.sort?.expression);
+ }
+ sort.uuid = element?.uuid ? element.uuid : sort.uuid;
+ return sort;
+ }
+
+ static readInterceptFrom = (element: any): InterceptFrom => {
+ const interceptFrom = element ? new InterceptFrom({...element.interceptFrom}) : new InterceptFrom();
+ interceptFrom.steps = CamelYamlStep.readSteps(element?.interceptFrom?.steps);
+ interceptFrom.uuid = element?.uuid ? element.uuid : interceptFrom.uuid;
+ return interceptFrom;
+ }
+
+ static readThrowException = (element: any): ThrowException => {
+ const throwException = element ? new ThrowException({...element.throwException}) : new ThrowException();
+ throwException.uuid = element?.uuid ? element.uuid : throwException.uuid;
+ return throwException;
+ }
+
+ static readTo = (element: any): To => {
+ if (typeof element.to !== 'object') element.to = {uri: element.to};
+ if (element && element.to && typeof element.to === 'string') element.to = {uri: element.to};
+ const to = element ? new To({...element.to}) : new To();
+ to.uuid = element?.uuid ? element.uuid : to.uuid;
+ return to;
+ }
+
+ static readFilter = (element: any): Filter => {
+ const filter = element ? new Filter({...element.filter}) : new Filter();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.filter);
+ if (implicitExpression){
+ filter.expression = new Expression({[implicitExpression]: element.filter[implicitExpression]});
+ delete (filter as any)[implicitExpression];
+ } else {
+ filter.expression = CamelYamlStep.readExpression(element?.filter?.expression);
+ }
+ filter.steps = CamelYamlStep.readSteps(element?.filter?.steps);
+ filter.uuid = element?.uuid ? element.uuid : filter.uuid;
+ return filter;
+ }
+
+ static readServiceCall = (element: any): ServiceCall => {
+ if (element && element.serviceCall && typeof element.serviceCall === 'string') element.serviceCall = {name: element.serviceCall};
+ const serviceCall = element ? new ServiceCall({...element.serviceCall}) : new ServiceCall();
+ serviceCall.uuid = element?.uuid ? element.uuid : serviceCall.uuid;
+ return serviceCall;
+ }
+
+ static readThrottle = (element: any): Throttle => {
+ const throttle = element ? new Throttle({...element.throttle}) : new Throttle();
+ throttle.correlationExpression = CamelYamlStep.readExpression(element?.throttle?.correlationExpression);
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.throttle);
+ if (implicitExpression){
+ throttle.expression = new Expression({[implicitExpression]: element.throttle[implicitExpression]});
+ delete (throttle as any)[implicitExpression];
+ } else {
+ throttle.expression = CamelYamlStep.readExpression(element?.throttle?.expression);
+ }
+ throttle.uuid = element?.uuid ? element.uuid : throttle.uuid;
+ return throttle;
+ }
+
+ static readWhenSkipSendToEndpoint = (element: any): WhenSkipSendToEndpoint => {
+ const whenSkipSendToEndpoint = element ? new WhenSkipSendToEndpoint({...element.whenSkipSendToEndpoint}) : new WhenSkipSendToEndpoint();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.whenSkipSendToEndpoint);
+ if (implicitExpression){
+ whenSkipSendToEndpoint.expression = new Expression({[implicitExpression]: element.whenSkipSendToEndpoint[implicitExpression]});
+ delete (whenSkipSendToEndpoint as any)[implicitExpression];
+ } else {
+ whenSkipSendToEndpoint.expression = CamelYamlStep.readExpression(element?.whenSkipSendToEndpoint?.expression);
+ }
+ whenSkipSendToEndpoint.steps = CamelYamlStep.readSteps(element?.whenSkipSendToEndpoint?.steps);
+ whenSkipSendToEndpoint.uuid = element?.uuid ? element.uuid : whenSkipSendToEndpoint.uuid;
+ return whenSkipSendToEndpoint;
+ }
+
+ static readRemoveProperties = (element: any): RemoveProperties => {
+ if (element && element.removeProperties && typeof element.removeProperties === 'string') element.removeProperties = {pattern: element.removeProperties};
+ const removeProperties = element ? new RemoveProperties({...element.removeProperties}) : new RemoveProperties();
+ removeProperties.uuid = element?.uuid ? element.uuid : removeProperties.uuid;
+ return removeProperties;
+ }
+
+ static readSetHeader = (element: any): SetHeader => {
+ const setHeader = element ? new SetHeader({...element.setHeader}) : new SetHeader();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.setHeader);
+ if (implicitExpression){
+ setHeader.expression = new Expression({[implicitExpression]: element.setHeader[implicitExpression]});
+ delete (setHeader as any)[implicitExpression];
+ } else {
+ setHeader.expression = CamelYamlStep.readExpression(element?.setHeader?.expression);
+ }
+ setHeader.uuid = element?.uuid ? element.uuid : setHeader.uuid;
+ return setHeader;
+ }
+
+ static readChoice = (element: any): Choice => {
+ const choiceStep = element ? new Choice({...element.choice}) : new Choice();
+ if (element?.choice?.otherwise !== undefined){
+ choiceStep.otherwise = CamelYamlStep.readOtherwise(element?.choice?.otherwise);
+ }
+ choiceStep.when = element && element?.choice && element?.choice?.when ? element?.choice?.when.map((x:any) => CamelYamlStep.readWhen(x)) :[]
+ choiceStep.uuid = element?.uuid ? element.uuid : choiceStep.uuid
+ return choiceStep
+ }
+
+ static readAggregate = (element: any): Aggregate => {
+ const aggregate = element ? new Aggregate({...element.aggregate}) : new Aggregate();
+ aggregate.completionPredicate = CamelYamlStep.readExpression(element?.aggregate?.completionPredicate);
+ aggregate.completionSizeExpression = CamelYamlStep.readExpression(element?.aggregate?.completionSizeExpression);
+ aggregate.completionTimeoutExpression = CamelYamlStep.readExpression(element?.aggregate?.completionTimeoutExpression);
+ aggregate.correlationExpression = CamelYamlStep.readExpression(element?.aggregate?.correlationExpression);
+ aggregate.steps = CamelYamlStep.readSteps(element?.aggregate?.steps);
+ aggregate.uuid = element?.uuid ? element.uuid : aggregate.uuid;
+ return aggregate;
+ }
+
+ static readRemoveProperty = (element: any): RemoveProperty => {
+ if (element && element.removeProperty && typeof element.removeProperty === 'string') element.removeProperty = {propertyName: element.removeProperty};
+ const removeProperty = element ? new RemoveProperty({...element.removeProperty}) : new RemoveProperty();
+ removeProperty.uuid = element?.uuid ? element.uuid : removeProperty.uuid;
+ return removeProperty;
+ }
+
+ static readRemoveHeader = (element: any): RemoveHeader => {
+ const removeHeader = element ? new RemoveHeader({...element.removeHeader}) : new RemoveHeader();
+ removeHeader.uuid = element?.uuid ? element.uuid : removeHeader.uuid;
+ return removeHeader;
+ }
+
+ static readScript = (element: any): Script => {
+ const script = element ? new Script({...element.script}) : new Script();
+ const implicitExpression = CamelYamlStep.readExpressionLanguage(element.script);
+ if (implicitExpression){
+ script.expression = new Expression({[implicitExpression]: element.script[implicitExpression]});
+ delete (script as any)[implicitExpression];
+ } else {
+ script.expression = CamelYamlStep.readExpression(element?.script?.expression);
+ }
+ script.uuid = element?.uuid ? element.uuid : script.uuid;
+ return script;
+ }
+
+ static readDoTry = (element: any): DoTry => {
+ const doTry = element ? new DoTry({...element.doTry}) : new DoTry();
+ doTry.doCatch = element && element?.doTry ? element?.doTry?.doCatch.map((x:any) => CamelYamlStep.readDoCatch(x)) :[];
+ doTry.doFinally = CamelYamlStep.readDoFinally(element?.doTry?.doFinally);
+ doTry.steps = CamelYamlStep.readSteps(element?.doTry?.steps);
+ doTry.uuid = element?.uuid ? element.uuid : doTry.uuid;
+ return doTry;
+ }
+
+ static readSetExchangePattern = (element: any): SetExchangePattern => {
+ if (element && element.setExchangePattern && typeof element.setExchangePattern === 'string') element.setExchangePattern = {pattern: element.setExchangePattern};
+ const setExchangePattern = element ? new SetExchangePattern({...element.setExchangePattern}) : new SetExchangePattern();
+ setExchangePattern.uuid = element?.uuid ? element.uuid : setExchangePattern.uuid;
+ return setExchangePattern;
+ }
+
+ static readTransacted = (element: any): Transacted => {
+ const transacted = element ? new Transacted({...element.transacted}) : new Transacted();
+ transacted.steps = CamelYamlStep.readSteps(element?.transacted?.steps);
+ transacted.uuid = element?.uuid ? element.uuid : transacted.uuid;
+ return transacted;
+ }
+
+ static readPipeline = (element: any): Pipeline => {
+ const pipeline = element ? new Pipeline({...element.pipeline}) : new Pipeline();
+ pipeline.steps = CamelYamlStep.readSteps(element?.pipeline?.steps);
+ pipeline.uuid = element?.uuid ? element.uuid : pipeline.uuid;
+ return pipeline;
+ }
+
+ static readUnmarshal = (element: any): Unmarshal => {
+ const unmarshal = element ? new Unmarshal({...element.unmarshal}) : new Unmarshal();
+ if (element.unmarshal?.any23 !== undefined) unmarshal.any23 = new dataFormat.Any23DataFormat(element.unmarshal.any23);
+ if (element.unmarshal?.asn1 !== undefined) unmarshal.asn1 = new dataFormat.ASN1DataFormat(element.unmarshal.asn1);
+ if (element.unmarshal?.avro !== undefined) unmarshal.avro = new dataFormat.AvroDataFormat(element.unmarshal.avro);
+ if (element.unmarshal?.barcode !== undefined) unmarshal.barcode = new dataFormat.BarcodeDataFormat(element.unmarshal.barcode);
+ if (element.unmarshal?.base64 !== undefined) unmarshal.base64 = new dataFormat.Base64DataFormat(element.unmarshal.base64);
+ if (element.unmarshal?.beanio !== undefined) unmarshal.beanio = new dataFormat.BeanioDataFormat(element.unmarshal.beanio);
+ if (element.unmarshal?.bindy !== undefined) unmarshal.bindy = new dataFormat.BindyDataFormat(element.unmarshal.bindy);
+ if (element.unmarshal?.cbor !== undefined) unmarshal.cbor = new dataFormat.CBORDataFormat(element.unmarshal.cbor);
+ if (element.unmarshal?.crypto !== undefined) unmarshal.crypto = new dataFormat.CryptoDataFormat(element.unmarshal.crypto);
+ if (element.unmarshal?.csv !== undefined) unmarshal.csv = new dataFormat.CsvDataFormat(element.unmarshal.csv);
+ if (element.unmarshal?.custom !== undefined) unmarshal.custom = new dataFormat.CustomDataFormat(element.unmarshal.custom);
+ if (element.unmarshal?.fhirJson !== undefined) unmarshal.fhirJson = new dataFormat.FhirJsonDataFormat(element.unmarshal.fhirJson);
+ if (element.unmarshal?.fhirXml !== undefined) unmarshal.fhirXml = new dataFormat.FhirXmlDataFormat(element.unmarshal.fhirXml);
+ if (element.unmarshal?.flatpack !== undefined) unmarshal.flatpack = new dataFormat.FlatpackDataFormat(element.unmarshal.flatpack);
+ if (element.unmarshal?.grok !== undefined) unmarshal.grok = new dataFormat.GrokDataFormat(element.unmarshal.grok);
+ if (element.unmarshal?.gzip !== undefined) unmarshal.gzip = new dataFormat.GzipDataFormat(element.unmarshal.gzip);
+ if (element.unmarshal?.hl7 !== undefined) unmarshal.hl7 = new dataFormat.HL7DataFormat(element.unmarshal.hl7);
+ if (element.unmarshal?.ical !== undefined) unmarshal.ical = new dataFormat.IcalDataFormat(element.unmarshal.ical);
+ if (element.unmarshal?.jacksonxml !== undefined) unmarshal.jacksonxml = new dataFormat.JacksonXMLDataFormat(element.unmarshal.jacksonxml);
+ if (element.unmarshal?.jaxb !== undefined) unmarshal.jaxb = new dataFormat.JaxbDataFormat(element.unmarshal.jaxb);
+ if (element.unmarshal?.json !== undefined) unmarshal.json = new dataFormat.JsonDataFormat(element.unmarshal.json);
+ if (element.unmarshal?.jsonApi !== undefined) unmarshal.jsonApi = new dataFormat.JsonApiDataFormat(element.unmarshal.jsonApi);
+ if (element.unmarshal?.lzf !== undefined) unmarshal.lzf = new dataFormat.LZFDataFormat(element.unmarshal.lzf);
+ if (element.unmarshal?.mimeMultipart !== undefined) unmarshal.mimeMultipart = new dataFormat.MimeMultipartDataFormat(element.unmarshal.mimeMultipart);
+ if (element.unmarshal?.pgp !== undefined) unmarshal.pgp = new dataFormat.PGPDataFormat(element.unmarshal.pgp);
+ if (element.unmarshal?.protobuf !== undefined) unmarshal.protobuf = new dataFormat.ProtobufDataFormat(element.unmarshal.protobuf);
+ if (element.unmarshal?.rss !== undefined) unmarshal.rss = new dataFormat.RssDataFormat(element.unmarshal.rss);
+ if (element.unmarshal?.secureXml !== undefined) unmarshal.secureXml = new dataFormat.XMLSecurityDataFormat(element.unmarshal.secureXml);
+ if (element.unmarshal?.soapjaxb !== undefined) unmarshal.soapjaxb = new dataFormat.SoapJaxbDataFormat(element.unmarshal.soapjaxb);
+ if (element.unmarshal?.syslog !== undefined) unmarshal.syslog = new dataFormat.SyslogDataFormat(element.unmarshal.syslog);
+ if (element.unmarshal?.tarfile !== undefined) unmarshal.tarfile = new dataFormat.TarFileDataFormat(element.unmarshal.tarfile);
+ if (element.unmarshal?.thrift !== undefined) unmarshal.thrift = new dataFormat.ThriftDataFormat(element.unmarshal.thrift);
+ if (element.unmarshal?.tidyMarkup !== undefined) unmarshal.tidyMarkup = new dataFormat.TidyMarkupDataFormat(element.unmarshal.tidyMarkup);
+ if (element.unmarshal?.univocityCsv !== undefined) unmarshal.univocityCsv = new dataFormat.UniVocityCsvDataFormat(element.unmarshal.univocityCsv);
+ if (element.unmarshal?.univocityFixed !== undefined) unmarshal.univocityFixed = new dataFormat.UniVocityFixedWidthDataFormat(element.unmarshal.univocityFixed);
+ if (element.unmarshal?.univocityTsv !== undefined) unmarshal.univocityTsv = new dataFormat.UniVocityTsvDataFormat(element.unmarshal.univocityTsv);
+ if (element.unmarshal?.xmlrpc !== undefined) unmarshal.xmlrpc = new dataFormat.XmlRpcDataFormat(element.unmarshal.xmlrpc);
+ if (element.unmarshal?.xstream !== undefined) unmarshal.xstream = new dataFormat.XStreamDataFormat(element.unmarshal.xstream);
+ if (element.unmarshal?.yaml !== undefined) unmarshal.yaml = new dataFormat.YAMLDataFormat(element.unmarshal.yaml);
+ if (element.unmarshal?.zip !== undefined) unmarshal.zip = new dataFormat.ZipDeflaterDataFormat(element.unmarshal.zip);
+ if (element.unmarshal?.zipfile !== undefined) unmarshal.zipfile = new dataFormat.ZipFileDataFormat(element.unmarshal.zipfile);
+ unmarshal.uuid = element?.uuid ? element.uuid : unmarshal.uuid;
+ return unmarshal;
+ }
+
+ static readSteps = (elements: any[] | undefined): CamelElement[] => {
+ const result: CamelElement[] = []
+ if (elements !== undefined){
+ elements.forEach(e => {
+ const stepName = Object.keys(e).filter(key => !['uuid', 'dslName'].includes(key))[0];
+ result.push(CamelYamlStep.readStep(CamelUtil.camelizeName(stepName, '-', true), e));
+ })
+ }
+ return result
+ }
+
+ static readExpressionLanguage = (init?: Partial<Expression>): string | undefined => {
+ if (init?.constant) return 'constant'
+ if (init?.csimple) return 'csimple'
+ if (init?.datasonnet) return 'datasonnet'
+ if (init?.exchangeProperty) return 'exchangeProperty'
+ if (init?.groovy) return 'groovy'
+ if (init?.header) return 'header'
+ if (init?.hl7terser) return 'hl7terser'
+ if (init?.joor) return 'joor'
+ if (init?.jsonpath) return 'jsonpath'
+ if (init?.method) return 'method'
+ if (init?.mvel) return 'mvel'
+ if (init?.ognl) return 'ognl'
+ if (init?.ref) return 'ref'
+ if (init?.simple) return 'simple'
+ if (init?.spel) return 'spel'
+ if (init?.tokenize) return 'tokenize'
+ if (init?.xpath) return 'xpath'
+ if (init?.xquery) return 'xquery'
+ if (init?.xtokenize) return 'xtokenize'
+ return undefined;
+ }
+}
+
diff --git a/karavan-core/src/core/model/CamelModel.ts b/karavan-core/src/core/model/CamelModel.ts
index fccc136..836709d 100644
--- a/karavan-core/src/core/model/CamelModel.ts
+++ b/karavan-core/src/core/model/CamelModel.ts
@@ -14,7 +14,7 @@ export class Metadata {
}
export class Spec {
- flows: FromStep[] = [];
+ flows: From[] = [];
public constructor(init?: Partial<Spec>) {
Object.assign(this, init);
@@ -51,17 +51,14 @@ export class CamelElement {
}
}
-export class ProcessorStep extends CamelElement {
-}
-
-export class ProcessorStepMeta {
- step?: ProcessorStep
+export class CamelElementMeta {
+ step?: CamelElement
parentUuid?: string
position: number = 0;
pathUuids: string [] = [];
- constructor(step?: ProcessorStep, parentUuid?: string, position?: number, pathUuids?: string []) {
+ constructor(step?: CamelElement, parentUuid?: string, position?: number, pathUuids?: string []) {
this.step = step;
this.parentUuid = parentUuid;
this.position = position || 0;
@@ -71,22 +68,13 @@ export class ProcessorStepMeta {
export class Policy extends CamelElement {
ref?: string
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Policy>) {
super('policy')
Object.assign(this, init)
}
}
-export class PolicyStep extends ProcessorStep {
- policy: Policy = new Policy()
-
- public constructor(init?: Partial<Policy>) {
- super('policyStep')
- Object.assign(this, {policy: new Policy({...init})})
- }
-}
-
export class ThrowException extends CamelElement {
exceptionType?: string
message?: string
@@ -97,15 +85,6 @@ export class ThrowException extends CamelElement {
Object.assign(this, init)
}
}
-export class ThrowExceptionStep extends ProcessorStep {
- throwException: ThrowException = new ThrowException()
-
- public constructor(init?: Partial<ThrowException>) {
- super('throwExceptionStep')
- Object.assign(this, {throwException: new ThrowException({...init})})
- }
-}
-
export class Choice extends CamelElement {
otherwise?: Otherwise
when?: When [] = []
@@ -115,15 +94,6 @@ export class Choice extends CamelElement {
Object.assign(this, init)
}
}
-export class ChoiceStep extends ProcessorStep {
- choice: Choice = new Choice()
-
- public constructor(init?: Partial<Choice>) {
- super('choiceStep')
- Object.assign(this, {choice: new Choice({...init})})
- }
-}
-
export class PollEnrich extends CamelElement {
aggregateOnException?: boolean
cacheSize?: number
@@ -139,15 +109,6 @@ export class PollEnrich extends CamelElement {
Object.assign(this, init)
}
}
-export class PollEnrichStep extends ProcessorStep {
- pollEnrich: PollEnrich = new PollEnrich()
-
- public constructor(init?: Partial<PollEnrich>) {
- super('pollEnrichStep')
- Object.assign(this, {pollEnrich: new PollEnrich({...init})})
- }
-}
-
export class SetBody extends CamelElement {
expression?: Expression
@@ -156,15 +117,6 @@ export class SetBody extends CamelElement {
Object.assign(this, init)
}
}
-export class SetBodyStep extends ProcessorStep {
- setBody: SetBody = new SetBody()
-
- public constructor(init?: Partial<SetBody>) {
- super('setBodyStep')
- Object.assign(this, {setBody: new SetBody({...init})})
- }
-}
-
export class Stop extends CamelElement {
public constructor(init?: Partial<Stop>) {
@@ -172,15 +124,6 @@ export class Stop extends CamelElement {
Object.assign(this, init)
}
}
-export class StopStep extends ProcessorStep {
- stop: Stop = new Stop()
-
- public constructor(init?: Partial<Stop>) {
- super('stopStep')
- Object.assign(this, {stop: new Stop({...init})})
- }
-}
-
export class ToD extends CamelElement {
allowOptimisedComponents?: boolean
autoStartComponents?: boolean
@@ -195,15 +138,6 @@ export class ToD extends CamelElement {
Object.assign(this, init)
}
}
-export class ToDStep extends ProcessorStep {
- toD: ToD = new ToD()
-
- public constructor(init?: Partial<ToD>) {
- super('toDStep')
- Object.assign(this, {toD: new ToD({...init})})
- }
-}
-
export class Process extends CamelElement {
ref?: string
@@ -212,15 +146,6 @@ export class Process extends CamelElement {
Object.assign(this, init)
}
}
-export class ProcessStep extends ProcessorStep {
- process: Process = new Process()
-
- public constructor(init?: Partial<Process>) {
- super('processStep')
- Object.assign(this, {process: new Process({...init})})
- }
-}
-
export class RemoveHeaders extends CamelElement {
excludePattern?: string
pattern?: string
@@ -230,15 +155,6 @@ export class RemoveHeaders extends CamelElement {
Object.assign(this, init)
}
}
-export class RemoveHeadersStep extends ProcessorStep {
- removeHeaders: RemoveHeaders = new RemoveHeaders()
-
- public constructor(init?: Partial<RemoveHeaders>) {
- super('removeHeadersStep')
- Object.assign(this, {removeHeaders: new RemoveHeaders({...init})})
- }
-}
-
export class Delay extends CamelElement {
asyncDelayed?: boolean
callerRunsWhenRejected?: boolean
@@ -250,15 +166,6 @@ export class Delay extends CamelElement {
Object.assign(this, init)
}
}
-export class DelayStep extends ProcessorStep {
- delay: Delay = new Delay()
-
- public constructor(init?: Partial<Delay>) {
- super('delayStep')
- Object.assign(this, {delay: new Delay({...init})})
- }
-}
-
export class Throttle extends CamelElement {
asyncDelayed?: boolean
callerRunsWhenRejected?: boolean
@@ -273,17 +180,8 @@ export class Throttle extends CamelElement {
Object.assign(this, init)
}
}
-export class ThrottleStep extends ProcessorStep {
- throttle: Throttle = new Throttle()
-
- public constructor(init?: Partial<Throttle>) {
- super('throttleStep')
- Object.assign(this, {throttle: new Throttle({...init})})
- }
-}
-
export class Otherwise extends CamelElement {
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Otherwise>) {
super('otherwise')
@@ -298,15 +196,6 @@ export class RemoveProperty extends CamelElement {
Object.assign(this, init)
}
}
-export class RemovePropertyStep extends ProcessorStep {
- removeProperty: RemoveProperty = new RemoveProperty()
-
- public constructor(init?: Partial<RemoveProperty>) {
- super('removePropertyStep')
- Object.assign(this, {removeProperty: new RemoveProperty({...init})})
- }
-}
-
export class Validate extends CamelElement {
expression?: Expression
@@ -315,15 +204,6 @@ export class Validate extends CamelElement {
Object.assign(this, init)
}
}
-export class ValidateStep extends ProcessorStep {
- validate: Validate = new Validate()
-
- public constructor(init?: Partial<Validate>) {
- super('validateStep')
- Object.assign(this, {validate: new Validate({...init})})
- }
-}
-
export class Sort extends CamelElement {
comparatorRef?: string
expression?: Expression
@@ -333,18 +213,9 @@ export class Sort extends CamelElement {
Object.assign(this, init)
}
}
-export class SortStep extends ProcessorStep {
- sort: Sort = new Sort()
-
- public constructor(init?: Partial<Sort>) {
- super('sortStep')
- Object.assign(this, {sort: new Sort({...init})})
- }
-}
-
export class From extends CamelElement {
parameters?: any
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
uri?: string
public constructor(init?: Partial<From>) {
@@ -352,15 +223,6 @@ export class From extends CamelElement {
Object.assign(this, init)
}
}
-export class FromStep extends ProcessorStep {
- from: From = new From()
-
- public constructor(init?: Partial<From>) {
- super('fromStep')
- Object.assign(this, {from: new From({...init})})
- }
-}
-
export class To extends CamelElement {
parameters?: any
pattern?: string
@@ -371,15 +233,6 @@ export class To extends CamelElement {
Object.assign(this, init)
}
}
-export class ToStep extends ProcessorStep {
- to: To = new To()
-
- public constructor(init?: Partial<To>) {
- super('toStep')
- Object.assign(this, {to: new To({...init})})
- }
-}
-
export class SetHeader extends CamelElement {
expression?: Expression
name?: string
@@ -389,15 +242,6 @@ export class SetHeader extends CamelElement {
Object.assign(this, init)
}
}
-export class SetHeaderStep extends ProcessorStep {
- setHeader: SetHeader = new SetHeader()
-
- public constructor(init?: Partial<SetHeader>) {
- super('setHeaderStep')
- Object.assign(this, {setHeader: new SetHeader({...init})})
- }
-}
-
export class OnCompletion extends CamelElement {
executorServiceRef?: string
mode?: string
@@ -405,7 +249,7 @@ export class OnCompletion extends CamelElement {
onFailureOnly?: boolean
onWhen?: When
parallelProcessing?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
useOriginalMessage?: boolean
public constructor(init?: Partial<OnCompletion>) {
@@ -413,15 +257,6 @@ export class OnCompletion extends CamelElement {
Object.assign(this, init)
}
}
-export class OnCompletionStep extends ProcessorStep {
- onCompletion: OnCompletion = new OnCompletion()
-
- public constructor(init?: Partial<OnCompletion>) {
- super('onCompletionStep')
- Object.assign(this, {onCompletion: new OnCompletion({...init})})
- }
-}
-
export class RemoveHeader extends CamelElement {
headerName?: string
name?: string
@@ -431,15 +266,6 @@ export class RemoveHeader extends CamelElement {
Object.assign(this, init)
}
}
-export class RemoveHeaderStep extends ProcessorStep {
- removeHeader: RemoveHeader = new RemoveHeader()
-
- public constructor(init?: Partial<RemoveHeader>) {
- super('removeHeaderStep')
- Object.assign(this, {removeHeader: new RemoveHeader({...init})})
- }
-}
-
export class Script extends CamelElement {
expression?: Expression
@@ -448,15 +274,6 @@ export class Script extends CamelElement {
Object.assign(this, init)
}
}
-export class ScriptStep extends ProcessorStep {
- script: Script = new Script()
-
- public constructor(init?: Partial<Script>) {
- super('scriptStep')
- Object.assign(this, {script: new Script({...init})})
- }
-}
-
export class Enrich extends CamelElement {
aggregateOnException?: boolean
allowOptimisedComponents?: boolean
@@ -473,15 +290,6 @@ export class Enrich extends CamelElement {
Object.assign(this, init)
}
}
-export class EnrichStep extends ProcessorStep {
- enrich: Enrich = new Enrich()
-
- public constructor(init?: Partial<Enrich>) {
- super('enrichStep')
- Object.assign(this, {enrich: new Enrich({...init})})
- }
-}
-
export class Log extends CamelElement {
logName?: string
loggerRef?: string
@@ -494,15 +302,6 @@ export class Log extends CamelElement {
Object.assign(this, init)
}
}
-export class LogStep extends ProcessorStep {
- log: Log = new Log()
-
- public constructor(init?: Partial<Log>) {
- super('logStep')
- Object.assign(this, {log: new Log({...init})})
- }
-}
-
export class Tod extends CamelElement {
allowOptimisedComponents?: boolean
autoStartComponents?: boolean
@@ -517,15 +316,6 @@ export class Tod extends CamelElement {
Object.assign(this, init)
}
}
-export class TodStep extends ProcessorStep {
- tod: Tod = new Tod()
-
- public constructor(init?: Partial<Tod>) {
- super('todStep')
- Object.assign(this, {tod: new Tod({...init})})
- }
-}
-
export class RemoveProperties extends CamelElement {
excludePattern?: string
pattern?: string
@@ -535,15 +325,6 @@ export class RemoveProperties extends CamelElement {
Object.assign(this, init)
}
}
-export class RemovePropertiesStep extends ProcessorStep {
- removeProperties: RemoveProperties = new RemoveProperties()
-
- public constructor(init?: Partial<RemoveProperties>) {
- super('removePropertiesStep')
- Object.assign(this, {removeProperties: new RemoveProperties({...init})})
- }
-}
-
export class Marshal extends CamelElement {
any23?: dataFormat.Any23DataFormat
asn1?: dataFormat.ASN1DataFormat
@@ -592,15 +373,6 @@ export class Marshal extends CamelElement {
Object.assign(this, init)
}
}
-export class MarshalStep extends ProcessorStep {
- marshal: Marshal = new Marshal()
-
- public constructor(init?: Partial<Marshal>) {
- super('marshalStep')
- Object.assign(this, {marshal: new Marshal({...init})})
- }
-}
-
export class Split extends CamelElement {
delimiter?: string
executorServiceRef?: string
@@ -609,7 +381,7 @@ export class Split extends CamelElement {
parallelAggregate?: boolean
parallelProcessing?: boolean
shareUnitOfWork?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
stopOnAggregateException?: boolean
stopOnException?: boolean
strategyMethodAllowNull?: boolean
@@ -623,35 +395,17 @@ export class Split extends CamelElement {
Object.assign(this, init)
}
}
-export class SplitStep extends ProcessorStep {
- split: Split = new Split()
-
- public constructor(init?: Partial<Split>) {
- super('splitStep')
- Object.assign(this, {split: new Split({...init})})
- }
-}
-
export class Transacted extends CamelElement {
ref?: string
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Transacted>) {
super('transacted')
Object.assign(this, init)
}
}
-export class TransactedStep extends ProcessorStep {
- transacted: Transacted = new Transacted()
-
- public constructor(init?: Partial<Transacted>) {
- super('transactedStep')
- Object.assign(this, {transacted: new Transacted({...init})})
- }
-}
-
export class InterceptFrom extends CamelElement {
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
uri?: string
public constructor(init?: Partial<InterceptFrom>) {
@@ -659,53 +413,26 @@ export class InterceptFrom extends CamelElement {
Object.assign(this, init)
}
}
-export class InterceptFromStep extends ProcessorStep {
- interceptFrom: InterceptFrom = new InterceptFrom()
-
- public constructor(init?: Partial<InterceptFrom>) {
- super('interceptFromStep')
- Object.assign(this, {interceptFrom: new InterceptFrom({...init})})
- }
-}
-
export class DoCatch extends CamelElement {
exception?: string [] = []
onWhen?: When
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<DoCatch>) {
super('doCatch')
Object.assign(this, init)
}
}
-export class DoCatchStep extends ProcessorStep {
- doCatch: DoCatch = new DoCatch()
-
- public constructor(init?: Partial<DoCatch>) {
- super('doCatchStep')
- Object.assign(this, {doCatch: new DoCatch({...init})})
- }
-}
-
export class CircuitBreaker extends CamelElement {
configurationRef?: string
onFallback?: OnFallback
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<CircuitBreaker>) {
super('circuitBreaker')
Object.assign(this, init)
}
}
-export class CircuitBreakerStep extends ProcessorStep {
- circuitBreaker: CircuitBreaker = new CircuitBreaker()
-
- public constructor(init?: Partial<CircuitBreaker>) {
- super('circuitBreakerStep')
- Object.assign(this, {circuitBreaker: new CircuitBreaker({...init})})
- }
-}
-
export class ConvertBodyTo extends CamelElement {
charset?: string
mandatory?: boolean
@@ -716,32 +443,14 @@ export class ConvertBodyTo extends CamelElement {
Object.assign(this, init)
}
}
-export class ConvertBodyToStep extends ProcessorStep {
- convertBodyTo: ConvertBodyTo = new ConvertBodyTo()
-
- public constructor(init?: Partial<ConvertBodyTo>) {
- super('convertBodyToStep')
- Object.assign(this, {convertBodyTo: new ConvertBodyTo({...init})})
- }
-}
-
export class Intercept extends CamelElement {
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Intercept>) {
super('intercept')
Object.assign(this, init)
}
}
-export class InterceptStep extends ProcessorStep {
- intercept: Intercept = new Intercept()
-
- public constructor(init?: Partial<Intercept>) {
- super('interceptStep')
- Object.assign(this, {intercept: new Intercept({...init})})
- }
-}
-
export class Unmarshal extends CamelElement {
any23?: dataFormat.Any23DataFormat
asn1?: dataFormat.ASN1DataFormat
@@ -790,33 +499,15 @@ export class Unmarshal extends CamelElement {
Object.assign(this, init)
}
}
-export class UnmarshalStep extends ProcessorStep {
- unmarshal: Unmarshal = new Unmarshal()
-
- public constructor(init?: Partial<Unmarshal>) {
- super('unmarshalStep')
- Object.assign(this, {unmarshal: new Unmarshal({...init})})
- }
-}
-
export class OnFallback extends CamelElement {
fallbackViaNetwork?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<OnFallback>) {
super('onFallback')
Object.assign(this, init)
}
}
-export class OnFallbackStep extends ProcessorStep {
- onFallback: OnFallback = new OnFallback()
-
- public constructor(init?: Partial<OnFallback>) {
- super('onFallbackStep')
- Object.assign(this, {onFallback: new OnFallback({...init})})
- }
-}
-
export class SetExchangePattern extends CamelElement {
pattern?: string
@@ -825,15 +516,6 @@ export class SetExchangePattern extends CamelElement {
Object.assign(this, init)
}
}
-export class SetExchangePatternStep extends ProcessorStep {
- setExchangePattern: SetExchangePattern = new SetExchangePattern()
-
- public constructor(init?: Partial<SetExchangePattern>) {
- super('setExchangePatternStep')
- Object.assign(this, {setExchangePattern: new SetExchangePattern({...init})})
- }
-}
-
export class RecipientList extends CamelElement {
cacheSize?: number
delimiter?: string
@@ -857,15 +539,6 @@ export class RecipientList extends CamelElement {
Object.assign(this, init)
}
}
-export class RecipientListStep extends ProcessorStep {
- recipientList: RecipientList = new RecipientList()
-
- public constructor(init?: Partial<RecipientList>) {
- super('recipientListStep')
- Object.assign(this, {recipientList: new RecipientList({...init})})
- }
-}
-
export class Bean extends CamelElement {
beanType?: string
cache?: boolean
@@ -878,22 +551,13 @@ export class Bean extends CamelElement {
Object.assign(this, init)
}
}
-export class BeanStep extends ProcessorStep {
- bean: Bean = new Bean()
-
- public constructor(init?: Partial<Bean>) {
- super('beanStep')
- Object.assign(this, {bean: new Bean({...init})})
- }
-}
-
export class Multicast extends CamelElement {
executorServiceRef?: string
onPrepareRef?: string
parallelAggregate?: boolean
parallelProcessing?: boolean
shareUnitOfWork?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
stopOnAggregateException?: boolean
stopOnException?: boolean
strategyMethodAllowNull?: boolean
@@ -907,15 +571,6 @@ export class Multicast extends CamelElement {
Object.assign(this, init)
}
}
-export class MulticastStep extends ProcessorStep {
- multicast: Multicast = new Multicast()
-
- public constructor(init?: Partial<Multicast>) {
- super('multicastStep')
- Object.assign(this, {multicast: new Multicast({...init})})
- }
-}
-
export class InOnly extends CamelElement {
parameters?: any
uri?: string
@@ -925,34 +580,16 @@ export class InOnly extends CamelElement {
Object.assign(this, init)
}
}
-export class InOnlyStep extends ProcessorStep {
- inOnly: InOnly = new InOnly()
-
- public constructor(init?: Partial<InOnly>) {
- super('inOnlyStep')
- Object.assign(this, {inOnly: new InOnly({...init})})
- }
-}
-
export class LoadBalance extends CamelElement {
customLoadBalancer?: string
inheritErrorHandler?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<LoadBalance>) {
super('loadBalance')
Object.assign(this, init)
}
}
-export class LoadBalanceStep extends ProcessorStep {
- loadBalance: LoadBalance = new LoadBalance()
-
- public constructor(init?: Partial<LoadBalance>) {
- super('loadBalanceStep')
- Object.assign(this, {loadBalance: new LoadBalance({...init})})
- }
-}
-
export class RoutingSlip extends CamelElement {
cacheSize?: number
expression?: Expression
@@ -964,15 +601,6 @@ export class RoutingSlip extends CamelElement {
Object.assign(this, init)
}
}
-export class RoutingSlipStep extends ProcessorStep {
- routingSlip: RoutingSlip = new RoutingSlip()
-
- public constructor(init?: Partial<RoutingSlip>) {
- super('routingSlipStep')
- Object.assign(this, {routingSlip: new RoutingSlip({...init})})
- }
-}
-
export class Rollback extends CamelElement {
markRollbackOnly?: boolean
markRollbackOnlyLast?: boolean
@@ -983,33 +611,15 @@ export class Rollback extends CamelElement {
Object.assign(this, init)
}
}
-export class RollbackStep extends ProcessorStep {
- rollback: Rollback = new Rollback()
-
- public constructor(init?: Partial<Rollback>) {
- super('rollbackStep')
- Object.assign(this, {rollback: new Rollback({...init})})
- }
-}
-
export class WhenSkipSendToEndpoint extends CamelElement {
expression?: Expression
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<WhenSkipSendToEndpoint>) {
super('whenSkipSendToEndpoint')
Object.assign(this, init)
}
}
-export class WhenSkipSendToEndpointStep extends ProcessorStep {
- whenSkipSendToEndpoint: WhenSkipSendToEndpoint = new WhenSkipSendToEndpoint()
-
- public constructor(init?: Partial<WhenSkipSendToEndpoint>) {
- super('whenSkipSendToEndpointStep')
- Object.assign(this, {whenSkipSendToEndpoint: new WhenSkipSendToEndpoint({...init})})
- }
-}
-
export class WireTap extends CamelElement {
allowOptimisedComponents?: boolean
autoStartComponents?: boolean
@@ -1023,7 +633,7 @@ export class WireTap extends CamelElement {
parameters?: any
pattern?: string
processorRef?: string
- setHeader?: SetHeaderStep [] = []
+ setHeader?: SetHeader [] = []
uri?: string
public constructor(init?: Partial<WireTap>) {
@@ -1031,40 +641,22 @@ export class WireTap extends CamelElement {
Object.assign(this, init)
}
}
-export class WireTapStep extends ProcessorStep {
- wireTap: WireTap = new WireTap()
-
- public constructor(init?: Partial<WireTap>) {
- super('wireTapStep')
- Object.assign(this, {wireTap: new WireTap({...init})})
- }
-}
-
export class Loop extends CamelElement {
breakOnShutdown?: boolean
copy?: boolean
doWhile?: boolean
expression?: Expression
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Loop>) {
super('loop')
Object.assign(this, init)
}
}
-export class LoopStep extends ProcessorStep {
- loop: Loop = new Loop()
-
- public constructor(init?: Partial<Loop>) {
- super('loopStep')
- Object.assign(this, {loop: new Loop({...init})})
- }
-}
-
export class InterceptSendToEndpoint extends CamelElement {
afterUri?: string
skipSendToOriginalEndpoint?: string
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
uri?: string
public constructor(init?: Partial<InterceptSendToEndpoint>) {
@@ -1072,52 +664,25 @@ export class InterceptSendToEndpoint extends CamelElement {
Object.assign(this, init)
}
}
-export class InterceptSendToEndpointStep extends ProcessorStep {
- interceptSendToEndpoint: InterceptSendToEndpoint = new InterceptSendToEndpoint()
-
- public constructor(init?: Partial<InterceptSendToEndpoint>) {
- super('interceptSendToEndpointStep')
- Object.assign(this, {interceptSendToEndpoint: new InterceptSendToEndpoint({...init})})
- }
-}
-
export class DoTry extends CamelElement {
- doCatch?: DoCatchStep [] = []
+ doCatch?: DoCatch [] = []
doFinally?: DoFinally
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<DoTry>) {
super('doTry')
Object.assign(this, init)
}
}
-export class DoTryStep extends ProcessorStep {
- doTry: DoTry = new DoTry()
-
- public constructor(init?: Partial<DoTry>) {
- super('doTryStep')
- Object.assign(this, {doTry: new DoTry({...init})})
- }
-}
-
export class Resequence extends CamelElement {
expression?: Expression
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Resequence>) {
super('resequence')
Object.assign(this, init)
}
}
-export class ResequenceStep extends ProcessorStep {
- resequence: Resequence = new Resequence()
-
- public constructor(init?: Partial<Resequence>) {
- super('resequenceStep')
- Object.assign(this, {resequence: new Resequence({...init})})
- }
-}
-
export class Expression extends CamelElement {
constant?: string
csimple?: string
@@ -1146,15 +711,6 @@ export class Expression extends CamelElement {
Object.assign(this, init)
}
}
-export class ExpressionStep extends ProcessorStep {
- expression: Expression = new Expression()
-
- public constructor(init?: Partial<Expression>) {
- super('expressionStep')
- Object.assign(this, {expression: new Expression({...init})})
- }
-}
-
export class ServiceCall extends CamelElement {
component?: string
configurationRef?: string
@@ -1172,15 +728,6 @@ export class ServiceCall extends CamelElement {
Object.assign(this, init)
}
}
-export class ServiceCallStep extends ProcessorStep {
- serviceCall: ServiceCall = new ServiceCall()
-
- public constructor(init?: Partial<ServiceCall>) {
- super('serviceCallStep')
- Object.assign(this, {serviceCall: new ServiceCall({...init})})
- }
-}
-
export class Kamelet extends CamelElement {
name?: string
parameters?: any
@@ -1190,15 +737,6 @@ export class Kamelet extends CamelElement {
Object.assign(this, init)
}
}
-export class KameletStep extends ProcessorStep {
- kamelet: Kamelet = new Kamelet()
-
- public constructor(init?: Partial<Kamelet>) {
- super('kameletStep')
- Object.assign(this, {kamelet: new Kamelet({...init})})
- }
-}
-
export class Sample extends CamelElement {
messageFrequency?: number
samplePeriod?: string
@@ -1209,15 +747,6 @@ export class Sample extends CamelElement {
Object.assign(this, init)
}
}
-export class SampleStep extends ProcessorStep {
- sample: Sample = new Sample()
-
- public constructor(init?: Partial<Sample>) {
- super('sampleStep')
- Object.assign(this, {sample: new Sample({...init})})
- }
-}
-
export class DynamicRouter extends CamelElement {
cacheSize?: number
expression?: Expression
@@ -1229,39 +758,21 @@ export class DynamicRouter extends CamelElement {
Object.assign(this, init)
}
}
-export class DynamicRouterStep extends ProcessorStep {
- dynamicRouter: DynamicRouter = new DynamicRouter()
-
- public constructor(init?: Partial<DynamicRouter>) {
- super('dynamicRouterStep')
- Object.assign(this, {dynamicRouter: new DynamicRouter({...init})})
- }
-}
-
export class Pipeline extends CamelElement {
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Pipeline>) {
super('pipeline')
Object.assign(this, init)
}
}
-export class PipelineStep extends ProcessorStep {
- pipeline: Pipeline = new Pipeline()
-
- public constructor(init?: Partial<Pipeline>) {
- super('pipelineStep')
- Object.assign(this, {pipeline: new Pipeline({...init})})
- }
-}
-
export class Saga extends CamelElement {
compensation?: string
completion?: string
completionMode?: string
propagation?: string
sagaServiceRef?: string
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
timeout?: string
timeoutInMilliseconds?: number
@@ -1270,15 +781,6 @@ export class Saga extends CamelElement {
Object.assign(this, init)
}
}
-export class SagaStep extends ProcessorStep {
- saga: Saga = new Saga()
-
- public constructor(init?: Partial<Saga>) {
- super('sagaStep')
- Object.assign(this, {saga: new Saga({...init})})
- }
-}
-
export class Threads extends CamelElement {
allowCoreThreadTimeOut?: boolean
callerRunsWhenRejected?: string
@@ -1296,18 +798,9 @@ export class Threads extends CamelElement {
Object.assign(this, init)
}
}
-export class ThreadsStep extends ProcessorStep {
- threads: Threads = new Threads()
-
- public constructor(init?: Partial<Threads>) {
- super('threadsStep')
- Object.assign(this, {threads: new Threads({...init})})
- }
-}
-
export class When extends CamelElement {
expression?: Expression
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<When>) {
super('when')
@@ -1326,50 +819,23 @@ export class ClaimCheck extends CamelElement {
Object.assign(this, init)
}
}
-export class ClaimCheckStep extends ProcessorStep {
- claimCheck: ClaimCheck = new ClaimCheck()
-
- public constructor(init?: Partial<ClaimCheck>) {
- super('claimCheckStep')
- Object.assign(this, {claimCheck: new ClaimCheck({...init})})
- }
-}
-
export class DoFinally extends CamelElement {
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<DoFinally>) {
super('doFinally')
Object.assign(this, init)
}
}
-export class DoFinallyStep extends ProcessorStep {
- doFinally: DoFinally = new DoFinally()
-
- public constructor(init?: Partial<DoFinally>) {
- super('doFinallyStep')
- Object.assign(this, {doFinally: new DoFinally({...init})})
- }
-}
-
export class Filter extends CamelElement {
expression?: Expression
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<Filter>) {
super('filter')
Object.assign(this, init)
}
}
-export class FilterStep extends ProcessorStep {
- filter: Filter = new Filter()
-
- public constructor(init?: Partial<Filter>) {
- super('filterStep')
- Object.assign(this, {filter: new Filter({...init})})
- }
-}
-
export class Aggregate extends CamelElement {
aggregateControllerRef?: string
aggregationRepositoryRef?: string
@@ -1393,7 +859,7 @@ export class Aggregate extends CamelElement {
ignoreInvalidCorrelationKeys?: boolean
optimisticLocking?: boolean
parallelProcessing?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
strategyMethodAllowNull?: boolean
strategyMethodName?: string
strategyRef?: string
@@ -1404,15 +870,6 @@ export class Aggregate extends CamelElement {
Object.assign(this, init)
}
}
-export class AggregateStep extends ProcessorStep {
- aggregate: Aggregate = new Aggregate()
-
- public constructor(init?: Partial<Aggregate>) {
- super('aggregateStep')
- Object.assign(this, {aggregate: new Aggregate({...init})})
- }
-}
-
export class Transform extends CamelElement {
expression?: Expression
@@ -1421,15 +878,6 @@ export class Transform extends CamelElement {
Object.assign(this, init)
}
}
-export class TransformStep extends ProcessorStep {
- transform: Transform = new Transform()
-
- public constructor(init?: Partial<Transform>) {
- super('transformStep')
- Object.assign(this, {transform: new Transform({...init})})
- }
-}
-
export class IdempotentConsumer extends CamelElement {
completionEager?: string
eager?: boolean
@@ -1437,22 +885,13 @@ export class IdempotentConsumer extends CamelElement {
messageIdRepositoryRef?: string
removeOnFailure?: boolean
skipDuplicate?: boolean
- steps?: ProcessorStep [] = []
+ steps?: CamelElement [] = []
public constructor(init?: Partial<IdempotentConsumer>) {
super('idempotentConsumer')
Object.assign(this, init)
}
}
-export class IdempotentConsumerStep extends ProcessorStep {
- idempotentConsumer: IdempotentConsumer = new IdempotentConsumer()
-
- public constructor(init?: Partial<IdempotentConsumer>) {
- super('idempotentConsumerStep')
- Object.assign(this, {idempotentConsumer: new IdempotentConsumer({...init})})
- }
-}
-
export class SetProperty extends CamelElement {
expression?: Expression
name?: string
@@ -1462,15 +901,6 @@ export class SetProperty extends CamelElement {
Object.assign(this, init)
}
}
-export class SetPropertyStep extends ProcessorStep {
- setProperty: SetProperty = new SetProperty()
-
- public constructor(init?: Partial<SetProperty>) {
- super('setPropertyStep')
- Object.assign(this, {setProperty: new SetProperty({...init})})
- }
-}
-
export class InOut extends CamelElement {
parameters?: any
uri?: string
@@ -1480,12 +910,3 @@ export class InOut extends CamelElement {
Object.assign(this, init)
}
}
-export class InOutStep extends ProcessorStep {
- inOut: InOut = new InOut()
-
- public constructor(init?: Partial<InOut>) {
- super('inOutStep')
- Object.assign(this, {inOut: new InOut({...init})})
- }
-}
-
diff --git a/karavan-core/test/addStep.spec.ts b/karavan-core/test/addStep.spec.ts
new file mode 100644
index 0000000..ea38862
--- /dev/null
+++ b/karavan-core/test/addStep.spec.ts
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {expect} from 'chai';
+import 'mocha';
+import {From, Integration, Log, When, Choice, Expression} from "../src/core/model/CamelModel";
+import {CamelApiExt} from "../src/core/api/CamelApiExt";
+
+describe('Add Step', () => {
+
+ const i = Integration.createNew("test")
+
+ const when1 = new When({expression:new Expression({simple:'$[body} != null'}), steps:[new Log({logName: 'log11', message: "hello11"})]})
+ const choice = new Choice({when:[when1]})
+ const flow1 = new From({uri: "direct1"});
+
+ flow1.steps?.push(choice);
+ i.spec.flows.push(flow1);
+
+ const when2 = new When({expression:new Expression({simple:'$[body} != "null"'}), steps:[new Log({logName: 'log22', message: "hello22"})]})
+ const i2 = CamelApiExt.addStepToIntegration(i, when2, choice.uuid);
+
+ it('Add Step', () => {
+ if (i2.spec.flows && i2.spec.flows.length > 0){
+ const f:From = i2.spec.flows[0];
+ const c:Choice = f.steps ? f.steps[0] : new Choice();
+ const w = c.when ? c.when[1] : undefined;
+ expect(c?.when?.length).to.equal(2);
+ }
+
+ });
+});
\ No newline at end of file
diff --git a/karavan-core/test/clone.spec.ts b/karavan-core/test/clone.spec.ts
new file mode 100644
index 0000000..2176a62
--- /dev/null
+++ b/karavan-core/test/clone.spec.ts
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {expect} from 'chai';
+import 'mocha';
+import {CamelYaml} from "../src/core/api/CamelYaml";
+import {
+ CamelElement,
+ From,
+ Integration,
+ To,
+ Log,
+ When,
+ Choice,
+ Otherwise,
+ Expression
+} from "../src/core/model/CamelModel";
+import {CamelUtil} from "../src/core/api/CamelUtil";
+import {Filter} from "../lib/model/CamelModel";
+
+describe('Clone', () => {
+
+ it('Clone integration', () => {
+ const i = Integration.createNew("test")
+
+ const when1 = new When({
+ expression: new Expression({simple: '$[body} != null'}),
+ steps: [new Log({logName: 'log11', message: "hello11"})]
+ })
+ const when2 = new When({
+ expression: new Expression({simple: '$[body} != "null"'}),
+ steps: [new Log({logName: 'log22', message: "hello22"})]
+ })
+ const otherwise = new Otherwise({steps: [new Log({logName: 'logX', message: "helloX"})]})
+ const choice = new Choice({when: [when1, when2], otherwise: otherwise})
+
+ const flow1 = new From({uri: "direct1"});
+ flow1.steps?.push(choice);
+ flow1.steps?.push(new To({uri: 'kamelet:kamelet2'}));
+ flow1.steps?.push(new To({uri: 'kamelet:kamelet2'}));
+ flow1.parameters = {httpMethodRestrict: 'POST'}
+ i.spec.flows.push(flow1);
+
+ const flow2 = new From({uri: "direct2"});
+ flow2.steps?.push(new Log({logName: 'log1', message: "hello1"}));
+ flow2.steps?.push(new Log({logName: 'log2', message: "hello2"}));
+
+ i.spec.flows.push(flow2);
+ const integ = CamelUtil.cloneIntegration(i);
+
+ const text1 = CamelYaml.integrationToYaml(i);
+ const text2 = CamelYaml.integrationToYaml(integ);
+ expect(text2).to.equal(text1);
+ });
+
+ it('Clone Log step', () => {
+ const log1: Log = new Log({logName: 'log1', message: "hello1"});
+ const log2: Log = CamelUtil.cloneStep(log1);
+ expect(log1.dslName).to.equal(log2.dslName);
+ expect(log1.logName).to.equal(log2.logName);
+ expect(log1.message).to.equal(log2.message);
+ });
+
+ it('Clone Filter step', () => {
+ const filter1: Filter = new Filter({expression: new Expression({simple:"${body} == null"}), steps: [new Log({logName:"log1"})]});
+ const filter2: Filter = CamelUtil.cloneStep(filter1);
+ expect(filter1.dslName).to.equal(filter2.dslName);
+ expect(filter1?.expression?.simple).to.equal(filter2?.expression?.simple);
+ expect(filter1?.steps?.length).to.equal(filter2?.steps?.length);
+ });
+});
\ No newline at end of file
diff --git a/karavan-core/test/camel_yaml/integration.spec.ts b/karavan-core/test/getToSteps.spec.ts
similarity index 59%
copy from karavan-core/test/camel_yaml/integration.spec.ts
copy to karavan-core/test/getToSteps.spec.ts
index 92ad9ec..cf787a6 100644
--- a/karavan-core/test/camel_yaml/integration.spec.ts
+++ b/karavan-core/test/getToSteps.spec.ts
@@ -15,23 +15,19 @@
* limitations under the License.
*/
import {expect} from 'chai';
-import * as fs from 'fs';
-import * as path from 'path';
import 'mocha';
-import {CamelYaml} from "../../src/core/api/CamelYaml";
-
-describe('CRD YAML to Integration', () => {
+import * as fs from 'fs';
+import {CamelApiExt} from "../lib/api/CamelApiExt";
+import {CamelYaml} from "../lib/api/CamelYaml";
- const yaml = fs.readFileSync('test/camel_yaml/integration1.yaml',{encoding:'utf8', flag:'r'});
+describe('getToSteps', () => {
- it('YAML <-> Object', () => {
- const i = CamelYaml.yamlToIntegration("test1.yaml", yaml);
- expect(i.metadata.name).to.equal('test1.yaml');
- expect(i.kind).to.equal('Integration');
- expect(i.spec.flows.length).to.equal(1);
- expect(i.crd).to.equal(true);
- const y = CamelYaml.integrationToYaml(i);
- expect(y).to.equal(yaml);
+ it('getToSteps', () => {
+ const yaml = fs.readFileSync('test/getToSteps.yaml',{encoding:'utf8', flag:'r'});
+ const i = CamelYaml.yamlToIntegration("test", yaml);
+ const c = CamelApiExt.getToStepsFromIntegration(i);
+ expect(2).to.equal(c.length);
+ expect('to').to.equal(c[0][0].dslName);
+ expect('kamelet').to.equal(c[1][0].dslName);
});
-
});
\ No newline at end of file
diff --git a/karavan-core/test/getToSteps.yaml b/karavan-core/test/getToSteps.yaml
new file mode 100644
index 0000000..be36f4f
--- /dev/null
+++ b/karavan-core/test/getToSteps.yaml
@@ -0,0 +1,36 @@
+apiVersion: camel.apache.org/v1
+kind: Integration
+metadata:
+ name: ''
+spec:
+ flows:
+ - from:
+ uri: kamelet:http-secured-source
+ steps:
+ - unmarshal:
+ json:
+ library: gson
+ - setBody:
+ expression:
+ constant: Hello Yaml !!!
+ - pollEnrich:
+ expression: {}
+ - log:
+ message: ${body}
+ - to:
+ uri: log:info:xxx
+ parameters:
+ level: 'OFF'
+ logMask: true
+ - choice:
+ when:
+ - expression: {}
+ steps:
+ - toD: {}
+ otherwise:
+ steps:
+ - kamelet:
+ name: kafka-not-secured-sink
+ parameters:
+ topic: topic1
+ brokers: localhost:9092
\ No newline at end of file
diff --git a/karavan-core/test/camel_yaml/integration.spec.ts b/karavan-core/test/integration.spec.ts
similarity index 89%
rename from karavan-core/test/camel_yaml/integration.spec.ts
rename to karavan-core/test/integration.spec.ts
index 92ad9ec..62e39c4 100644
--- a/karavan-core/test/camel_yaml/integration.spec.ts
+++ b/karavan-core/test/integration.spec.ts
@@ -18,11 +18,11 @@ import {expect} from 'chai';
import * as fs from 'fs';
import * as path from 'path';
import 'mocha';
-import {CamelYaml} from "../../src/core/api/CamelYaml";
+import {CamelYaml} from "../src/core/api/CamelYaml";
describe('CRD YAML to Integration', () => {
- const yaml = fs.readFileSync('test/camel_yaml/integration1.yaml',{encoding:'utf8', flag:'r'});
+ const yaml = fs.readFileSync('test/integration1.yaml',{encoding:'utf8', flag:'r'});
it('YAML <-> Object', () => {
const i = CamelYaml.yamlToIntegration("test1.yaml", yaml);
diff --git a/karavan-core/test/camel_yaml/integration1.yaml b/karavan-core/test/integration1.yaml
similarity index 100%
rename from karavan-core/test/camel_yaml/integration1.yaml
rename to karavan-core/test/integration1.yaml
index bb2d904..0687d00 100644
--- a/karavan-core/test/camel_yaml/integration1.yaml
+++ b/karavan-core/test/integration1.yaml
@@ -6,9 +6,9 @@ spec:
flows:
- from:
uri: kamelet:timer-source
- steps:
- - log:
- message: wwwww
parameters:
period: 1000
message: qqq
+ steps:
+ - log:
+ message: wwwww
diff --git a/karavan-core/test/new-api.spec.ts b/karavan-core/test/new-api.spec.ts
new file mode 100644
index 0000000..45283c2
--- /dev/null
+++ b/karavan-core/test/new-api.spec.ts
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {expect} from 'chai';
+import 'mocha';
+import {CamelYaml} from "../src/core/api/CamelYaml";
+import {CamelElement, From, Integration, To, Log, When, Choice, Otherwise, Expression} from "../src/core/model/CamelModel";
+
+describe('Test new model and api', () => {
+
+ const i = Integration.createNew("test")
+
+ const when1 = new When({expression:new Expression({simple:'$[body} != null'}), steps:[new Log({logName: 'log11', message: "hello11"})]})
+ const when2 = new When({expression:new Expression({simple:'$[body} != "null"'}), steps:[new Log({logName: 'log22', message: "hello22"})]})
+ const otherwise = new Otherwise({steps:[new Log({logName: 'logX', message: "helloX"})]})
+ const choice = new Choice({when:[when1, when2], otherwise: otherwise})
+
+ const flow1 = new From({uri: "direct1"});
+ flow1.steps?.push(choice);
+ flow1.steps?.push(new To({uri: 'kamelet:kamelet2'}));
+ flow1.steps?.push(new To({uri: 'kamelet:kamelet2'}));
+ flow1.parameters = {httpMethodRestrict: 'POST'}
+ i.spec.flows.push(flow1);
+
+ const flow2 = new From({uri: "direct2"});
+ flow2.steps?.push(new Log({logName: 'log1', message: "hello1"}));
+ flow2.steps?.push(new Log({logName: 'log2', message: "hello2"}));
+
+ i.spec.flows.push(flow2);
+ const text1 = CamelYaml.integrationToYaml(i);
+
+ const integ = CamelYaml.yamlToIntegration("test", text1);
+ const text2 = CamelYaml.integrationToYaml(integ);
+
+ it('New API YAML <-> Object', () => {
+ expect(text2).to.equal(text1);
+ });
+});
\ No newline at end of file
diff --git a/karavan-core/test/camel_yaml/plain.spec.ts b/karavan-core/test/plain.spec.ts
similarity index 85%
rename from karavan-core/test/camel_yaml/plain.spec.ts
rename to karavan-core/test/plain.spec.ts
index aa3d14a..3f3261b 100644
--- a/karavan-core/test/camel_yaml/plain.spec.ts
+++ b/karavan-core/test/plain.spec.ts
@@ -18,11 +18,11 @@ import {expect} from 'chai';
import * as fs from 'fs';
import * as path from 'path';
import 'mocha';
-import {CamelYaml} from "../../src/core/api/CamelYaml";
+import {CamelYaml} from "../src/core/api/CamelYaml";
describe('Plain YAML to integration', () => {
- const yaml = fs.readFileSync('test/camel_yaml/route1.yaml',{encoding:'utf8', flag:'r'});
+ const yaml = fs.readFileSync('test/plain1.yaml',{encoding:'utf8', flag:'r'});
it('YAML <-> Object', () => {
const i = CamelYaml.yamlToIntegration("test1.yaml", yaml);
@@ -30,7 +30,7 @@ describe('Plain YAML to integration', () => {
expect(i.kind).to.equal('Integration');
expect(i.spec.flows.length).to.equal(1);
expect(i.crd).to.equal(false);
- expect(i.spec.flows[0].from.uri).to.equal('kamelet:timer-source');
+ expect(i.spec.flows[0].uri).to.equal('kamelet:timer-source');
const y = CamelYaml.integrationToYaml(i);
expect(y).to.equal(yaml);
});
diff --git a/karavan-core/test/camel_yaml/route1.yaml b/karavan-core/test/plain1.yaml
similarity index 100%
rename from karavan-core/test/camel_yaml/route1.yaml
rename to karavan-core/test/plain1.yaml
index 1763e85..bef518b 100644
--- a/karavan-core/test/camel_yaml/route1.yaml
+++ b/karavan-core/test/plain1.yaml
@@ -1,8 +1,8 @@
- from:
uri: kamelet:timer-source
- steps:
- - log:
- message: wwwww
parameters:
period: 1000
message: qqq
+ steps:
+ - log:
+ message: wwwww
diff --git a/karavan-core/test/tsconfig.testing.json b/karavan-core/test/tsconfig.testing.json
index 38ba881..fa33e1e 100644
--- a/karavan-core/test/tsconfig.testing.json
+++ b/karavan-core/test/tsconfig.testing.json
@@ -2,7 +2,13 @@
"compilerOptions": {
"module": "commonjs",
"target": "es6",
- "jsx": "react"
+ "jsx": "react",
+ "lib": [
+ "dom",
+ "dom.iterable",
+ "esnext",
+ "ES2021.String"
+ ]
},
"include": ["**/*.spec.ts"]
}
\ No newline at end of file
diff --git a/karavan-core/test/updateStep.spec.ts b/karavan-core/test/updateStep.spec.ts
new file mode 100644
index 0000000..059dbb0
--- /dev/null
+++ b/karavan-core/test/updateStep.spec.ts
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {expect} from 'chai';
+import 'mocha';
+import {From, Integration, Log, When, Choice, Expression} from "../src/core/model/CamelModel";
+import {CamelApiExt} from "../src/core/api/CamelApiExt";
+import {CamelUtil} from "../lib/api/CamelUtil";
+import {Filter} from "../lib/model/CamelModel";
+
+describe('Update Step', () => {
+
+ it('Update Expression in When clause', () => {
+ const i = Integration.createNew("test")
+ const when1 = new When({expression:new Expression({simple:'$[body} != null'}), steps:[new Log({logName: 'log11', message: "hello11"})]})
+ const choice = new Choice({when:[when1]})
+ const flow1 = new From({uri: "direct1"});
+ flow1.steps?.push(choice);
+ i.spec.flows.push(flow1);
+ const when2:When = CamelUtil.cloneStep(when1);
+ if (when2 && when2.expression){
+ when2.expression.simple = '$[body} == "hello world"';
+ }
+ const i2 = CamelApiExt.updateIntegration(i, when2, choice.uuid);
+ if (i2.spec.flows && i2.spec.flows.length > 0){
+ const f:From = i2.spec.flows[0];
+ const c:Choice = f.steps ? f.steps[0] : new Choice();
+ const w = c.when ? c.when[0] : undefined;
+ expect(w?.expression?.simple).to.equal('$[body} == "hello world"');
+ }
+ });
+
+ it('Update Expression in Filter clause', () => {
+ const i = Integration.createNew("test")
+ const filter = new Filter({expression:new Expression({simple:'$[body} != null'}), steps:[new Log({logName: 'log11', message: "hello11"})]})
+ const flow1 = new From({uri: "direct1"});
+ flow1.steps?.push(filter);
+ i.spec.flows.push(flow1);
+ const filter1:Filter = CamelUtil.cloneStep(filter);
+ if (filter1 && filter1.expression){
+ filter1.expression.simple = '$[body} == "hello world"';
+ }
+ const i2 = CamelApiExt.updateIntegration(i, filter1, filter.uuid);
+ if (i2.spec.flows && i2.spec.flows.length > 0){
+ const from:From = i2.spec.flows[0];
+ const f:Filter = from.steps ? from.steps[0] : new Filter();
+ expect(f?.expression?.simple).to.equal('$[body} == "hello world"');
+ }
+ });
+});
\ No newline at end of file
diff --git a/karavan-core/tsconfig.json b/karavan-core/tsconfig.json
index 684e869..9861a1d 100644
--- a/karavan-core/tsconfig.json
+++ b/karavan-core/tsconfig.json
@@ -8,7 +8,8 @@
"lib": [
"dom",
"dom.iterable",
- "esnext"
+ "esnext",
+ "ES2021.String"
]
},
"include": ["src"],
diff --git a/karavan-designer/package.json b/karavan-designer/package.json
index 941cd69..5985504 100644
--- a/karavan-designer/package.json
+++ b/karavan-designer/package.json
@@ -1,6 +1,7 @@
{
"name": "karavan-designer",
"version": "0.0.10",
+ "license": "Apache-2.0",
"dependencies": {
"@patternfly/patternfly": "^4.132.2",
"@patternfly/react-code-editor": "^4.3.42",
diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx
index e84a054..c59b064 100644
--- a/karavan-designer/src/App.tsx
+++ b/karavan-designer/src/App.tsx
@@ -52,7 +52,7 @@ class App extends React.Component<Props, State> {
' constant: "Hello Yaml !!!"\n' +
' - pollEnrich:\n' +
' expression: {}\n' +
- ' - log: \'${body}\'\n' +
+ ' - log: "${body}"\n' +
' - to: \n' +
' uri: "log:info:xxx"\n' +
' parameters:\n' +
diff --git a/karavan-designer/src/designer/DslConnections.tsx b/karavan-designer/src/designer/DslConnections.tsx
index c52ed6a..207d29b 100644
--- a/karavan-designer/src/designer/DslConnections.tsx
+++ b/karavan-designer/src/designer/DslConnections.tsx
@@ -65,16 +65,16 @@ export class DslConnections extends React.Component<Props, State> {
getIncomings(): InOut[] {
const result: InOut[] = [];
- this.state.integration.spec.flows.forEach((flow, index) => {
- const uri = flow.from.uri;
+ this.state.integration.spec.flows.forEach((from, index) => {
+ const uri = from.uri;
if (uri && uri.startsWith("kamelet")) {
const kamelet = KameletApi.findKameletByUri(uri);
if (kamelet && kamelet.metadata.labels["camel.apache.org/kamelet.type"] === 'source') {
- const i = new InOut('in', flow.uuid, index * 60, 0, 0, CamelUi.getIcon(flow.from));
+ const i = new InOut('in', from.uuid, index * 60, 0, 0, CamelUi.getIcon(from));
result.push(i);
}
} else if (uri && !uri.startsWith("kamelet")) {
- const i = new InOut('in', flow.uuid, index * 60, 0, 0, undefined, ComponentApi.getComponentNameFromUri(uri));
+ const i = new InOut('in', from.uuid, index * 60, 0, 0, undefined, ComponentApi.getComponentNameFromUri(uri));
result.push(i);
}
})
@@ -88,15 +88,15 @@ export class DslConnections extends React.Component<Props, State> {
set.forEach((level) => {
toSteps.filter(data => data[1] === level).forEach((data, index, all) => {
const element: CamelElement = data[0];
- if ((element as any).to) {
- const uri: string = (element as any).to.uri;
+ if (element.dslName === 'to') {
+ const uri: string = (element as any).uri;
const i = new InOut('out', element.uuid, index * 60, 500, index, undefined, ComponentApi.getComponentNameFromUri(uri));
result.push(i);
- } else if ((element as any).kamelet) {
- const name: string = (element as any).kamelet.name;
+ } else if (element.dslName === 'kamelet') {
+ const name: string = (element as any).name;
const kamelet = KameletApi.findKameletByName(name);
if (kamelet && kamelet.metadata.labels["camel.apache.org/kamelet.type"] === 'sink') {
- const i = new InOut('out', element.uuid, index * 60, 500, index, CamelUi.getIcon((element as any).kamelet), undefined);
+ const i = new InOut('out', element.uuid, index * 60, 500, index, CamelUi.getIcon(element), undefined);
result.push(i);
}
}
diff --git a/karavan-designer/src/designer/DslElement.tsx b/karavan-designer/src/designer/DslElement.tsx
index d5bcbda..dd9fcfe 100644
--- a/karavan-designer/src/designer/DslElement.tsx
+++ b/karavan-designer/src/designer/DslElement.tsx
@@ -21,8 +21,7 @@ import {
import './karavan.css';
import AddIcon from "@patternfly/react-icons/dist/js/icons/plus-circle-icon";
import DeleteIcon from "@patternfly/react-icons/dist/js/icons/times-icon";
-import {CamelElement, Otherwise, ProcessorStep, When} from "karavan-core/lib/model/CamelModel";
-import {CamelApi} from "karavan-core/lib/api/CamelApi";
+import {CamelElement, Otherwise, When} from "karavan-core/lib/model/CamelModel";
import {CamelUi} from "karavan-core/lib/api/CamelUi";
import {EventBus} from "karavan-core/lib/api/EventBus";
@@ -39,7 +38,6 @@ interface Props {
interface State {
step: CamelElement,
- element: CamelElement,
showSelector: boolean
tabIndex: string | number
selectedUuid: string
@@ -51,7 +49,6 @@ export class DslElement extends React.Component<Props, State> {
public state: State = {
step: this.props.step,
- element: this.props.step.dslName === 'otherwise' ? this.props.step : CamelApi.elementFromStep(this.props.step),
showSelector: false,
tabIndex: 0,
selectedUuid: this.props.selectedUuid,
@@ -67,7 +64,7 @@ export class DslElement extends React.Component<Props, State> {
openSelector = (evt: React.MouseEvent) => {
evt.stopPropagation();
- this.props.openSelector.call(this, this.state.step.uuid, this.state.element.dslName);
+ this.props.openSelector.call(this, this.state.step.uuid, this.state.step.dslName);
}
closeDslSelector = () => {
@@ -88,8 +85,8 @@ export class DslElement extends React.Component<Props, State> {
return this.state.selectedUuid === this.state.step.uuid
}
- getSteps = (): ProcessorStep[] => {
- return (this.state.element as any).steps
+ getSteps = (): CamelElement[] => {
+ return (this.state.step as any).steps
}
hasSteps = (): boolean => {
@@ -98,15 +95,15 @@ export class DslElement extends React.Component<Props, State> {
}
getWhens = (): When[] => {
- return (this.state.element as any).when
+ return (this.state.step as any).when
}
getOtherwise = (): Otherwise => {
- return (this.state.element as any).otherwise
+ return (this.state.step as any).otherwise
}
horizontal = (): boolean => {
- return ['choice', 'multicast'].includes(this.state.element.dslName);
+ return ['choice', 'multicast'].includes(this.state.step.dslName);
}
isRoot = (): boolean => {
@@ -127,18 +124,18 @@ export class DslElement extends React.Component<Props, State> {
return (
<div className="header"
style={
- ["choice", "multicast"].includes(this.state.element.dslName)
+ ["choice", "multicast"].includes(this.state.step.dslName)
? {width: "100%", fontWeight: this.isSelected() ? "bold" : "normal"}
: {fontWeight: this.isSelected() ? "bold" : "normal"}
}
ref={el => {
- if (el && (this.state.step.dslName === 'fromStep' || this.state.step.dslName === 'toStep' || this.state.step.dslName === 'kameletStep')) EventBus.sendPosition(this.state.step, el.getBoundingClientRect());
+ if (el && (this.state.step.dslName === 'from' || this.state.step.dslName === 'to' || this.state.step.dslName === 'kamelet')) EventBus.sendPosition(this.state.step, el.getBoundingClientRect());
}}>
<img draggable={false}
- src={CamelUi.getIcon(this.state.element)}
+ src={CamelUi.getIcon(this.state.step)}
className="icon" alt="icon">
</img>
- <Text>{CamelUi.getTitle(this.state.element)}</Text>
+ <Text>{CamelUi.getTitle(this.state.step)}</Text>
<button type="button" aria-label="Delete" onClick={e => this.delete(e)}
className="delete-button">
<DeleteIcon noVerticalAlign/>
@@ -157,8 +154,8 @@ export class DslElement extends React.Component<Props, State> {
}
getHeaderTooltip = (): string | undefined => {
- if (CamelUi.isShowExpressionTooltip(this.state.element)) return CamelUi.getExpressionTooltip(this.state.element);
- if (CamelUi.isShowUriTooltip(this.state.element)) return CamelUi.getUriTooltip(this.state.element);
+ if (CamelUi.isShowExpressionTooltip(this.state.step)) return CamelUi.getExpressionTooltip(this.state.step);
+ if (CamelUi.isShowUriTooltip(this.state.step)) return CamelUi.getUriTooltip(this.state.step);
return undefined;
}
@@ -171,7 +168,7 @@ export class DslElement extends React.Component<Props, State> {
}
hasBorder = ():boolean => {
- return this.state.element.hasSteps() || ['choice', 'from'].includes(this.state.element.dslName);
+ return this.state.step.hasSteps() || ['choice', 'from'].includes(this.state.step.dslName);
}
render() {
@@ -184,7 +181,7 @@ export class DslElement extends React.Component<Props, State> {
borderStyle: this.isSelected() ? "dashed" : (this.hasBorder() ? "dotted" : "none"),
borderColor: this.isSelected() ? this.props.borderColorSelected : this.props.borderColor,
marginTop: this.isRoot() ? "16px" : "",
- zIndex: this.state.step.dslName === 'toStep' ? 20 : 10,
+ zIndex: this.state.step.dslName === 'to' ? 20 : 10,
boxShadow: this.state.isDraggedOver ? "0px 0px 1px 2px " + this.props.borderColorSelected : "none",
}}
onClick={event => this.selectElement(event)}
@@ -201,14 +198,14 @@ export class DslElement extends React.Component<Props, State> {
onDragOver={event => {
event.preventDefault();
event.stopPropagation();
- if (this.state.element.dslName !== 'from' && !this.state.isDragging) {
+ if (this.state.step.dslName !== 'from' && !this.state.isDragging) {
this.setState({isDraggedOver: true});
}
}}
onDragEnter={event => {
event.preventDefault();
event.stopPropagation();
- if (this.state.element.dslName !== 'from') {
+ if (this.state.step.dslName !== 'from') {
this.setState({isDraggedOver: true});
}
}}
@@ -228,17 +225,17 @@ export class DslElement extends React.Component<Props, State> {
this.props.moveElement?.call(this, sourceUuid, targetUuid);
}
}}
- draggable={!['from', 'when', 'otherwise'].includes(this.state.element.dslName)}
+ draggable={!['from', 'when', 'otherwise'].includes(this.state.step.dslName)}
>
{this.getElementHeader()}
- {this.state.element.hasSteps() && !this.horizontal() && this.getArrow()}
- <div className={this.state.element.dslName}>
- {this.state.element.hasSteps() &&
+ {this.state.step.hasSteps() && !this.horizontal() && this.getArrow()}
+ <div className={this.state.step.dslName}>
+ {this.state.step.hasSteps() &&
<div className="steps" style={this.horizontal() ? {display: "flex", flexDirection: "row"} : {}}>
{this.getSteps().map((step, index) => (
<div key={step.uuid}
style={this.horizontal() ? {marginRight: (index < this.getSteps().length - 1) ? "6px" : "0"} : {}}>
- {this.state.element.hasSteps() && this.horizontal() && this.getArrow()}
+ {this.state.step.hasSteps() && this.horizontal() && this.getArrow()}
<DslElement
openSelector={this.props.openSelector}
deleteElement={this.props.deleteElement}
@@ -253,16 +250,16 @@ export class DslElement extends React.Component<Props, State> {
))}
</div>
}
- {this.state.element.hasSteps() &&
+ {this.state.step.hasSteps() &&
<Tooltip position={"bottom"}
- content={<div>{"Add element to " + CamelUi.getTitle(this.state.element)}</div>}>
+ content={<div>{"Add element to " + CamelUi.getTitle(this.state.step)}</div>}>
<button type="button" aria-label="Add" onClick={e => this.openSelector(e)}
- className={this.state.element.dslName === 'from' ? "add-button-from" : "add-button"}>
+ className={this.state.step.dslName === 'from' ? "add-button-from" : "add-button"}>
<AddIcon noVerticalAlign/>
</button>
</Tooltip>
}
- {this.state.element.dslName === 'choice' &&
+ {this.state.step.dslName === 'choice' &&
<Tooltip position={"bottom"} content={<div>{"Add element to Choice"}</div>}>
<button type="button" aria-label="Add" onClick={e => this.openSelector(e)}
className="add-button">
@@ -270,7 +267,7 @@ export class DslElement extends React.Component<Props, State> {
</button>
</Tooltip>
}
- {this.state.element.dslName === 'choice' &&
+ {this.state.step.dslName === 'choice' &&
<div className={this.getWhens().length > 0 ? "whens" : ""}
style={this.horizontal() ? {display: "flex", flexDirection: "row"} : {}}>
{this.getWhens().map((when, index) => (
diff --git a/karavan-designer/src/designer/DslPath.tsx b/karavan-designer/src/designer/DslPath.tsx
index 003c8ad..a90ceb1 100644
--- a/karavan-designer/src/designer/DslPath.tsx
+++ b/karavan-designer/src/designer/DslPath.tsx
@@ -64,7 +64,7 @@ export class DslPath extends React.Component<Props, State> {
}
setPosition(evt: DslPosition) {
- if (evt.step.dslName === 'fromStep'){
+ if (evt.step.dslName === 'from'){
this.setState({inout:"in", left: 46, top: (evt.rect.top + 20), width: (evt.rect.x) - 46});
} else {
this.setState({inout:"out", left: evt.rect.x + evt.rect.width, top: (evt.rect.top + 20), width: (evt.rect.x + evt.rect.width + 200)});
diff --git a/karavan-designer/src/designer/DslProperties.tsx b/karavan-designer/src/designer/DslProperties.tsx
index 2c1f737..c4d1f54 100644
--- a/karavan-designer/src/designer/DslProperties.tsx
+++ b/karavan-designer/src/designer/DslProperties.tsx
@@ -35,6 +35,7 @@ import {ComponentApi} from "karavan-core/lib/api/ComponentApi";
import {DataFormatField} from "./field/DataFormatField";
import {DslPropertyField} from "./field/DslPropertyField";
import {DataFormat} from "karavan-core/lib/model/CamelDataFormat";
+import {CamelUtil} from "karavan-core/lib/api/CamelUtil";
interface Props {
integration: Integration,
@@ -47,7 +48,6 @@ interface Props {
interface State {
integration: Integration,
step?: CamelElement,
- element?: CamelElement,
selectStatus: Map<string, boolean>
isShowAdvanced: boolean
}
@@ -56,7 +56,6 @@ export class DslProperties extends React.Component<Props, State> {
public state: State = {
step: this.props.step,
- element: this.props.step ? CamelApi.elementFromStep(this.props.step) : undefined,
integration: this.props.integration,
selectStatus: new Map<string, boolean>(),
isShowAdvanced: false
@@ -67,22 +66,21 @@ export class DslProperties extends React.Component<Props, State> {
}
propertyChanged = (fieldId: string, value: string | number | boolean | any) => {
- if (this.state.step && this.state.element) {
- const clone = CamelYaml.cloneStep(this.state.step);
- (clone as any)[this.state.element?.dslName][fieldId] = value;
+ if (this.state.step) {
+ const clone = CamelUtil.cloneStep(this.state.step);
+ (clone as any)[fieldId] = value;
this.setStep(clone)
this.props.onPropertyUpdate?.call(this, clone, this.state.step.uuid);
}
}
dataFormatChanged = (dataFormat: string, value?: DataFormat) => {
- if (this.state.step && this.state.element){
- if (this.state.element?.dslName === 'unmarshal') {
+ if (this.state.step && this.state.step){
+ if (this.state.step?.dslName === 'unmarshal') {
const e:any = {unmarshal: {}};
e.unmarshal[dataFormat] = value ? value : {};
const unmarshal = CamelApi.createUnmarshal(e);
unmarshal.uuid = this.state.step.uuid;
- unmarshal.unmarshal.uuid = this.state.element.uuid;
this.setStep(unmarshal);
this.props.onPropertyUpdate?.call(this, unmarshal, this.state.step.uuid);
} else {
@@ -90,7 +88,6 @@ export class DslProperties extends React.Component<Props, State> {
e.marshal[dataFormat] = value ? value : {};
const marshal = CamelApi.createMarshal(e);
marshal.uuid = this.state.step.uuid;
- marshal.marshal.uuid = this.state.element.uuid;
this.setStep(marshal);
this.props.onPropertyUpdate?.call(this, marshal, this.state.step.uuid);
}
@@ -98,32 +95,28 @@ export class DslProperties extends React.Component<Props, State> {
}
expressionChanged = (language: string, value: string | undefined) => {
- if (this.state.step && this.state.element) {
- const clone = (CamelYaml.cloneStep(this.state.step));
+ if (this.state.step) {
+ const clone = (CamelUtil.cloneStep(this.state.step));
const e: any = {};
e.language = language;
e[language] = value;
const exp: any = new Expression(e);
- if (this.state.element?.dslName === 'when') {
- (clone as any).expression = exp;
- } else {
- (clone as any)[this.state.element?.dslName].expression = exp;
- }
+ (clone as any).expression = exp;
this.setStep(clone);
this.props.onPropertyUpdate?.call(this, clone, this.state.step.uuid);
}
}
parametersChanged = (parameter: string, value: string | number | boolean | any, pathParameter?: boolean) => {
- if (this.state.step && this.state.element) {
+ if (this.state.step && this.state.step) {
if (pathParameter) {
- const uri = ComponentApi.buildComponentUri((this.state.element as any).uri, parameter, value);
+ const uri = ComponentApi.buildComponentUri((this.state.step as any).uri, parameter, value);
this.propertyChanged("uri", uri);
} else {
- const clone = (CamelYaml.cloneStep(this.state.step));
- const parameters: any = {...(clone as any)[this.state.element?.dslName].parameters};
+ const clone = (CamelUtil.cloneStep(this.state.step));
+ const parameters: any = {...(clone as any).parameters};
parameters[parameter] = value;
- (clone as any)[this.state.element?.dslName].parameters = parameters;
+ (clone as any).parameters = parameters;
this.setStep(clone);
this.props.onPropertyUpdate?.call(this, clone, this.state.step.uuid);
}
@@ -139,7 +132,6 @@ export class DslProperties extends React.Component<Props, State> {
setStep = (step?: CamelElement) => {
this.setState({
step: step,
- element: step ? CamelApi.elementFromStep(step) : undefined,
selectStatus: new Map<string, boolean>()
});
}
@@ -163,11 +155,11 @@ export class DslProperties extends React.Component<Props, State> {
}
getComponentHeader = (): JSX.Element => {
- const title = this.state.element && CamelUi.getTitle(this.state.element)
- const kamelet = this.state.element && CamelUi.getKamelet(this.state.element)
- const description = this.state.element && kamelet
+ const title = this.state.step && CamelUi.getTitle(this.state.step)
+ const kamelet = this.state.step && CamelUi.getKamelet(this.state.step)
+ const description = this.state.step && kamelet
? kamelet.spec.definition.description
- : this.state.element?.dslName ? CamelMetadataApi.getCamelModelMetadata(this.state.element?.dslName)?.description : title;
+ : this.state.step?.dslName ? CamelMetadataApi.getCamelModelMetadata(this.state.step?.dslName)?.description : title;
return (
<div className="headers">
<Title headingLevel="h1" size="md">{title}</Title>
@@ -180,20 +172,20 @@ export class DslProperties extends React.Component<Props, State> {
return (
<div key={this.state.step ? this.state.step.uuid : 'integration'} className='properties'>
<Form autoComplete="off">
- {this.state.element === undefined && this.getIntegrationHeader()}
- {this.state.element && this.getComponentHeader()}
- {this.state.element && CamelApiExt.getElementProperties(this.state.element.dslName).map((property: PropertyMeta) =>
+ {this.state.step === undefined && this.getIntegrationHeader()}
+ {this.state.step && this.getComponentHeader()}
+ {this.state.step && CamelApiExt.getElementProperties(this.state.step.dslName).map((property: PropertyMeta) =>
<DslPropertyField property={property}
- element={this.state.element}
- value={this.state.element ? (this.state.element as any)[property.name] : undefined}
+ element={this.state.step}
+ value={this.state.step ? (this.state.step as any)[property.name] : undefined}
onExpressionChange={this.expressionChanged}
onParameterChange={this.parametersChanged}
onDataFormatChange={this.dataFormatChanged}
onChange={this.propertyChanged} />
)}
- {this.state.element && ['marshal', 'unmarshal'].includes(this.state.element.dslName) &&
+ {this.state.step && ['marshal', 'unmarshal'].includes(this.state.step.dslName) &&
<DataFormatField
- element={this.state.element}
+ element={this.state.step}
onDataFormatChange={this.dataFormatChanged} />
}
</Form>
diff --git a/karavan-designer/src/designer/DslSelector.tsx b/karavan-designer/src/designer/DslSelector.tsx
index 2edcc2c..4fd4e72 100644
--- a/karavan-designer/src/designer/DslSelector.tsx
+++ b/karavan-designer/src/designer/DslSelector.tsx
@@ -23,7 +23,7 @@ import {
import './karavan.css';
import {CamelUi} from "karavan-core/lib/api/CamelUi";
import {DslMetaModel} from "karavan-core/lib/model/DslMetaModel";
-import {CamelApi} from "karavan-core/lib/api/CamelApi";
+import {CamelUtil} from "karavan-core/lib/api/CamelUtil";
interface Props {
show: boolean,
@@ -112,7 +112,7 @@ export class DslSelector extends React.Component<Props, State> {
<Tabs style={{overflow: 'hidden'}} activeKey={this.state.tabIndex} onSelect={this.selectTab}>
{CamelUi.getSelectorLabels(this.props.parentType).map((label, index) => (
<Tab eventKey={label[0]} key={"tab-" + label[0]}
- title={<TabTitleText>{CamelApi.capitalizeName(label[0])}</TabTitleText>}
+ title={<TabTitleText>{CamelUtil.capitalizeName(label[0])}</TabTitleText>}
translate={undefined} onAuxClick={undefined} onAuxClickCapture={undefined}>
<Gallery key={"gallery-" + label[0]} hasGutter className="dsl-gallery">
{CamelUi.sortSelectorModels(CamelUi.getSelectorModels(label[0], label[1], this.props.parentType))
diff --git a/karavan-designer/src/designer/KaravanDesigner.tsx b/karavan-designer/src/designer/KaravanDesigner.tsx
index 46dcca3..79d708a 100644
--- a/karavan-designer/src/designer/KaravanDesigner.tsx
+++ b/karavan-designer/src/designer/KaravanDesigner.tsx
@@ -29,6 +29,7 @@ import {CamelElement, Integration} from "karavan-core/lib/model/CamelModel";
import {CamelYaml} from "karavan-core/lib/api/CamelYaml";
import {CamelApiExt} from "karavan-core/lib/api/CamelApiExt";
import {CamelApi} from "karavan-core/lib/api/CamelApi";
+import {CamelUtil} from "karavan-core/lib/api/CamelUtil";
import {DslConnections} from "./DslConnections";
import {EventBus} from "karavan-core/lib/api/EventBus";
@@ -90,12 +91,12 @@ export class KaravanDesigner extends React.Component<Props, State> {
};
getCode = (integration: Integration): string => {
- const clone = CamelYaml.cloneIntegration(integration);
+ const clone = CamelUtil.cloneIntegration(integration);
return CamelYaml.integrationToYaml(clone);
}
onPropertyUpdate = (element: CamelElement, updatedUuid: string) => {
- const clone = CamelYaml.cloneIntegration(this.state.integration);
+ const clone = CamelUtil.cloneIntegration(this.state.integration);
const i = CamelApiExt.updateIntegration(clone, element, updatedUuid);
this.setState({integration: i, key: Math.random().toString()});
}
@@ -126,19 +127,19 @@ export class KaravanDesigner extends React.Component<Props, State> {
onDslSelect = (dsl: DslMetaModel, parentId: string) => {
switch (dsl.dsl) {
case 'from' :
- const from = CamelApi.createStep(dsl.dsl, {from: {uri: dsl.uri}});
+ const from = CamelApi.createStep(dsl.dsl, {uri: dsl.uri});
this.addStep(from, parentId)
break;
case 'to' :
- const to = CamelApi.createStep(dsl.dsl, {to: {uri: dsl.uri}});
+ const to = CamelApi.createStep(dsl.dsl, {uri: dsl.uri});
this.addStep(to, parentId)
break;
case 'toD' :
- const toD = CamelApi.createStep(dsl.dsl, {toD: {uri: dsl.uri}});
+ const toD = CamelApi.createStep(dsl.dsl, {uri: dsl.uri});
this.addStep(toD, parentId)
break;
case 'kamelet' :
- const kamelet = CamelApi.createStep(dsl.dsl, {kamelet: {name: dsl.name}});
+ const kamelet = CamelApi.createStep(dsl.dsl,{name: dsl.name});
this.addStep(kamelet, parentId)
break;
default:
@@ -150,7 +151,7 @@ export class KaravanDesigner extends React.Component<Props, State> {
addStep = (step: CamelElement, parentId: string) => {
const i = CamelApiExt.addStepToIntegration(this.state.integration, step, parentId);
- const clone = CamelYaml.cloneIntegration(i);
+ const clone = CamelUtil.cloneIntegration(i);
this.setState({
integration: clone,
key: Math.random().toString(),
@@ -166,7 +167,7 @@ export class KaravanDesigner extends React.Component<Props, State> {
moveElement = (source: string, target: string) => {
const i = CamelApiExt.moveElement(this.state.integration, source, target);
- const clone = CamelYaml.cloneIntegration(i);
+ const clone = CamelUtil.cloneIntegration(i);
const selectedStep = CamelApiExt.findElement(clone, source);
this.setState({
integration: clone,
@@ -190,8 +191,8 @@ export class KaravanDesigner extends React.Component<Props, State> {
<DslConnections key={this.state.key + "-connections"}
integration={this.state.integration}
/>
- {this.state.integration.spec.flows.map((flow, index) => (
- <DslElement key={flow.uuid + this.state.key}
+ {this.state.integration.spec.flows.map((from, index) => (
+ <DslElement key={from.uuid + this.state.key}
openSelector={this.openSelector}
deleteElement={this.deleteElement}
selectElement={this.selectElement}
@@ -199,7 +200,7 @@ export class KaravanDesigner extends React.Component<Props, State> {
selectedUuid={this.state.selectedUuid}
borderColor={this.props.borderColor}
borderColorSelected={this.props.borderColorSelected}
- step={flow}/>
+ step={from}/>
))}
<div className="add-flow">
<Button
diff --git a/karavan-designer/src/designer/field/DataFormatField.tsx b/karavan-designer/src/designer/field/DataFormatField.tsx
index 202e2d7..802998a 100644
--- a/karavan-designer/src/designer/field/DataFormatField.tsx
+++ b/karavan-designer/src/designer/field/DataFormatField.tsx
@@ -22,7 +22,6 @@ import {
SelectVariant,
SelectDirection,
SelectOption,
- TextArea,
} from '@patternfly/react-core';
import '../karavan.css';
import "@patternfly/patternfly/patternfly.css";
diff --git a/karavan-designer/src/designer/field/DslPropertyField.tsx b/karavan-designer/src/designer/field/DslPropertyField.tsx
index ca44fff..93cfc13 100644
--- a/karavan-designer/src/designer/field/DslPropertyField.tsx
+++ b/karavan-designer/src/designer/field/DslPropertyField.tsx
@@ -28,7 +28,7 @@ import {
import '../karavan.css';
import "@patternfly/patternfly/patternfly.css";
import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon";
-import {CamelApi} from "karavan-core/lib/api/CamelApi";
+import {CamelUtil} from "karavan-core/lib/api/CamelUtil";
import { PropertyMeta} from "karavan-core/lib/api/CamelMetadata";
import {CamelApiExt} from "karavan-core/lib/api/CamelApiExt";
import {ExpressionField} from "./ExpressionField";
@@ -86,7 +86,7 @@ export class DslPropertyField extends React.Component<Props, State> {
return (
<FormGroup
key={property.name}
- label={CamelApi.capitalizeName(property.displayName)}
+ label={CamelUtil.capitalizeName(property.displayName)}
fieldId={property.name}
labelIcon={property.description ?
<Popover
diff --git a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelApiGenerator.java b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelApiGenerator.java
new file mode 100644
index 0000000..8513478
--- /dev/null
+++ b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelApiGenerator.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.karavan.generator;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public final class CamelApiGenerator extends AbstractGenerator {
+
+ public String generate(Map<String, List<ElementProp>> models, Map<String, String> processors, Map<String, String> propertyToMapStrings){
+ StringBuilder camelApi = new StringBuilder();
+ camelApi.append(
+ "/**\n" +
+ " * Generated by karavan build tools - do NOT edit this file!\n" +
+ " */\n");
+ camelApi.append("import {\n");
+ camelApi.append(" CamelElement, \n");
+ camelApi.append(" CamelElementMeta, \n");
+ camelApi.append(" From, \n");
+ camelApi.append(" Expression, \n");
+ processors.values().forEach(s -> {
+ if (s.equalsIgnoreCase("otherwise")) {
+ camelApi.append(" Otherwise, \n");
+ } else if (s.equalsIgnoreCase("when")) {
+ camelApi.append(" When, \n");
+ } else {
+ camelApi.append(" ").append(s).append(",\n");
+ }
+ });
+ camelApi.append("} from '../model/CamelModel' \n");
+ camelApi.append("import * as dataFormat from '../model/CamelDataFormat'; \n");
+ camelApi.append("import {CamelUtil} from \"./CamelUtil\"; \n\n");
+
+ camelApi.append("export class CamelApi { \n\n");
+
+ camelApi.append(
+ " static createStep = (name: string, body: any, clone: boolean = false): CamelElement => {\n" +
+ " const newBody = CamelUtil.camelizeBody(name, body, clone);\n" +
+ " switch (name){\n" +
+ " case 'from': return CamelApi.createFrom(newBody);\n" +
+ " case 'expression': return CamelApi.createExpression(newBody);\n");
+ processors.values().forEach(s ->
+ camelApi.append(" case '").append(deCapitalize(s)).append("': return CamelApi.create").append(capitalize(s)).append("(newBody);\n"));
+ camelApi.append(" default: return new CamelElement('');\n");
+ camelApi.append(" }\n");
+ camelApi.append(" }\n");
+
+
+ camelApi.append(
+ " static createExpression = (element: any): Expression => {\n" +
+ " return new Expression({...element})\n" +
+ " }\n");
+ camelApi.append(createCreateFunction("from", models.get("from"), "uri"));
+
+ processors.values().forEach((model) -> camelApi.append(createCreateFunction(model, models.get(model), propertyToMapStrings.get(model))));
+
+
+ camelApi.append(
+ " static createSteps = (elements: any[] | undefined): CamelElement[] => {\n" +
+ " const result: CamelElement[] = []\n" +
+ " if (elements !== undefined){\n" +
+ " elements.forEach(e => {\n" +
+ " result.push(CamelApi.createStep(CamelUtil.camelizeName(e.dslName, '-', true), e));\n" +
+ " })\n" +
+ " }\n" +
+ " return result\n" +
+ " }\n\n");
+
+ // addStep functions
+ camelApi.append(
+ " static addStep = (steps: CamelElement[], step: CamelElement, parentId: string, position?: number): CamelElement[] => {\n" +
+ " const result: CamelElement[] = [];\n" +
+ " steps.forEach(el => {\n" +
+ " switch (el.dslName) {\n");
+ models.entrySet().forEach(s -> {
+ String name = deCapitalize(s.getKey());
+ String stepClass = capitalize(s.getKey());
+ String stepField = deCapitalize(s.getKey());
+
+ if (name.equals("choice")) {
+ camelApi.append(getTemplateFile("CamelApi.addStep.choiceStep.tx").concat("\n"));
+ } else if (name.equals("otherwise")) {
+ camelApi.append(getTemplateFile("CamelApi.addStep.otherwise.tx").concat("\n"));
+ } else if (name.equals("when")) {
+ camelApi.append(getTemplateFile("CamelApi.addStep.when.tx").concat("\n"));
+ } else if (s.getValue().stream().filter(e -> e.name.equals("steps")).count() > 0) {
+ camelApi.append(String.format(
+ " case '%1$s':\n" +
+ " const %3$sChildren = (el as %2$s).steps || [];\n" +
+ " if (el.uuid === parentId) position !== undefined ? %3$sChildren.splice(position, 0, step) : %3$sChildren.push(step);\n" +
+ " else (el as %2$s).steps = CamelApi.addStep(%3$sChildren, step, parentId, position);\n" +
+ " break;\n",
+ stepField, stepClass, name));
+ }
+ });
+ camelApi.append(
+ " }\n" +
+ " result.push(el);\n" +
+ " })\n" +
+ " return result;\n" +
+ " }\n\n");
+
+
+ // deleteStep functions
+ camelApi.append(
+ " static deleteStep = (steps: CamelElement[] | undefined, uuidToDelete: string): CamelElement[] => {\n" +
+ " const result: CamelElement[] = []\n" +
+ " if (steps !== undefined){\n" +
+ " steps.forEach(step => {\n" +
+ " if (step.uuid !== uuidToDelete){\n" +
+ " switch (step.dslName){\n");
+ models.entrySet().forEach(s -> {
+ String name = deCapitalize(s.getKey());
+ String stepClass = capitalize(s.getKey());
+ String stepField = deCapitalize(s.getKey());
+ if (name.equals("otherwise")) {
+ camelApi.append(" case 'otherwise': (step as Otherwise).steps = CamelApi.deleteStep((step as Otherwise).steps, uuidToDelete); break;\n");
+ } else if (name.equals("when")) {
+ camelApi.append(" case 'when': (step as When).steps = CamelApi.deleteStep((step as When).steps, uuidToDelete); break;\n");
+ } else if (name.equals("choice")) {
+ camelApi.append(" case 'choice':\n" +
+ " const otherwise = (step as Choice).otherwise;\n" +
+ " if (otherwise && otherwise.uuid === uuidToDelete) {\n" +
+ " (step as Choice).otherwise = undefined;\n" +
+ " } else if (otherwise && otherwise.uuid !== uuidToDelete) {\n" +
+ " otherwise.steps = CamelApi.deleteStep(otherwise.steps, uuidToDelete);\n" +
+ " (step as Choice).otherwise = otherwise;\n" +
+ " }\n" +
+ " (step as Choice).when = CamelApi.deleteWhen((step as Choice).when, uuidToDelete);\n" +
+ " break;\n");
+ } else if (s.getValue().stream().filter(e -> e.name.equals("steps")).count() > 0) {
+ camelApi.append(String.format(" case '%s': (step as %s).steps = CamelApi.deleteStep((step as %s).steps, uuidToDelete); break;\n",
+ stepField, stepClass, stepClass));
+ }
+ });
+ camelApi.append(
+ " }\n" +
+ " result.push(step);\n" +
+ " }\n" +
+ " })\n" +
+ " }\n" +
+ " return result\n" +
+ " }\n\n");
+ camelApi.append(getTemplateFile("CamelApi.deleteWhen.tx").concat("\n\n"));
+
+
+ // findStep functions
+ camelApi.append(getTemplateFile("CamelApi.findStep.header.tx").concat("\n"));
+ models.entrySet().forEach(s -> {
+ String name = deCapitalize(s.getKey());
+ String stepClass = capitalize(s.getKey());
+ String stepField = deCapitalize(s.getKey());
+
+ if (name.equals("choice")) {
+ camelApi.append(getTemplateFile("CamelApi.findStep.choiceStep.tx").concat("\n"));
+ } else if (name.equals("otherwise")) {
+ camelApi.append(getTemplateFile("CamelApi.findStep.otherwise.tx").concat("\n"));
+ } else if (name.equals("when")) {
+ camelApi.append(getTemplateFile("CamelApi.findStep.when.tx").concat("\n"));
+ } else if (s.getValue().stream().filter(e -> e.name.equals("steps")).count() > 0) {
+ camelApi.append(String.format(
+ " case '%1$s':\n" +
+ " result = CamelApi.findStep((step as %2$s).steps, uuid, step.uuid, result);\n" +
+ " if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);\n" +
+ " break;\n",
+ stepField, stepClass));
+ }
+ });
+ camelApi.append(getTemplateFile("CamelApi.findStep.footer.tx").concat("\n\n"));
+
+ // Expression language finder
+ camelApi.append(" static getExpressionLanguage = (init?: Partial<Expression>): string | undefined => {\n");
+ models.get("expression").forEach(el -> {
+ if (!el.name.equals("language"))
+ camelApi.append(String.format(" if (init?.%s) return '%s'\n", el.name, el.name));
+ });
+ camelApi.append(" return undefined;\n");
+ camelApi.append(" }\n");
+
+ camelApi.append("}\n").append(System.lineSeparator());
+ return camelApi.toString();
+ }
+
+ private String createCreateFunction(String name, List<ElementProp> elProps, String propertyToMapStrings) {
+ if (name.equalsIgnoreCase("otherwise")) {
+ return getTemplateFile("CamelApi.createOtherwise.tx").concat("\n\n");
+ } else if (name.equalsIgnoreCase("when")) {
+ return getTemplateFile("CamelApi.createWhen.tx").concat("\n\n");
+ } else if (name.equalsIgnoreCase("choice")) {
+ return getTemplateFile("CamelApi.createChoice.tx").concat("\n\n");
+ }
+ String stepClass = capitalize(name);
+ String stepField = deCapitalize(name);
+ String elementName = deCapitalize(name);
+ String funcName = "create".concat(capitalize(name));
+ StringBuilder f = new StringBuilder();
+ f.append(String.format(" static %s = (element: any): %s => {\n", funcName, stepClass));
+ if (stepClass.equals("To") || stepClass.equals("Tod")) {
+ f.append(String.format(" if (typeof element !== 'object') element = {uri: element};\n", elementName));
+ }
+ // for oneOf string or object Definitions
+ if (propertyToMapStrings != null){
+ String p = deCapitalize(camelize(propertyToMapStrings, "-"));
+ f.append(String.format(" if (element && typeof element === 'string') element = {%2$s: element};\n", elementName, p));
+ }
+ f.append(String.format(" const %1$s = element ? new %2$s({...element}) : new %2$s();\n", stepField, stepClass, elementName));
+ elProps.stream().forEach(e -> {
+ if (e.name.equals("steps")) {
+ f.append(String.format(" %1$s.steps = CamelApi.createSteps(element?.steps);\n", stepField, elementName));
+ } else if (e.isArray && e.isArrayTypeClass) {
+ f.append(String.format(" %1$s.%3$s = element && element?.%2$s ? element?.%2$s?.%3$s.map((x:any) => CamelApi.create%4$s(x)) :[];\n", stepField, elementName, e.name, e.arrayType));
+ } else if (e.name.equalsIgnoreCase("expression")) {
+ f.append(String.format(" const implicitExpression = CamelApi.getExpressionLanguage(element);\n", elementName));
+ f.append(String.format(" if (implicitExpression){\n"));
+ f.append(String.format(" %1$s.expression = new Expression({[implicitExpression]: element[implicitExpression]});\n", stepField, elementName));
+ f.append(String.format(" delete (%1$s as any)[implicitExpression];\n", stepField));
+ f.append(String.format(" } else {\n"));
+ f.append(String.format(" %1$s.expression = CamelApi.createExpression(element?.expression);\n", stepField));
+ f.append(String.format(" }\n"));
+ } else if (e.typeCode.startsWith("dataFormat.")) {
+ String temp = " if (element.%1$s !== undefined) %2$s.%1$s = new %3$s(element.%1$s);\n";
+ f.append(String.format(temp, e.name, stepField, e.typeCode));
+ } else if (e.isObject) {
+ f.append(String.format(" %s.%s = CamelApi.create%s(element?.%s?.%s);\n", stepField, e.name, e.type, elementName, e.name));
+ }
+ });
+ f.append(String.format(" %s.uuid = element?.uuid ? element.uuid : %s.uuid;\n", stepField, stepField));
+ f.append(String.format(" return %s;\n", stepField));
+ f.append(" }\n\n");
+ return f.toString();
+ }
+
+ public String getTemplateFile(String name) {
+ try {
+ InputStream inputStream = CamelModelGenerator.class.getClassLoader().getResourceAsStream(name);
+ String data = new BufferedReader(new InputStreamReader(inputStream))
+ .lines().collect(Collectors.joining(System.getProperty("line.separator")));
+ return data;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+}
diff --git a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelModelGenerator.java b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelModelGenerator.java
index 7157b68..3119da6 100644
--- a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelModelGenerator.java
+++ b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelModelGenerator.java
@@ -20,7 +20,6 @@ import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -39,15 +38,16 @@ public final class CamelModelGenerator extends AbstractGenerator {
public static void generate() throws Exception {
CamelModelGenerator g = new CamelModelGenerator();
g.createModels(
- "karavan-generator/src/main/resources/camel-model.template",
+ "karavan-generator/src/main/resources/CamelModel.ts",
"karavan-generator/src/main/resources/camel-metadata.template",
"karavan-core/src/core/model/CamelModel.ts",
"karavan-core/src/core/api/CamelApi.ts",
+ "karavan-core/src/core/api/CamelYamlSteps.ts",
"karavan-core/src/core/api/CamelMetadata.ts"
);
}
- private void createModels(String template, String metadataTemplate, String targetModel, String targetApi, String targetMetadata) throws Exception {
+ private void createModels(String template, String metadataTemplate, String targetModel, String targetApi, String camelYamlSteps, String targetMetadata) throws Exception {
String camelYamlDSL = getCamelYamlDSL();
JsonObject definitions = new JsonObject(camelYamlDSL).getJsonObject("items").getJsonObject("definitions");
@@ -99,209 +99,19 @@ public final class CamelModelGenerator extends AbstractGenerator {
models.forEach((name, elementProps) -> {
String pcode = generateElementCode(name, elementProps);
camelModel.append(pcode).append(System.lineSeparator());
- if (!name.equalsIgnoreCase("otherwise") && !name.equalsIgnoreCase("when")) {
- camelModel.append(generateStepCode(name)).append(System.lineSeparator());
- }
});
vertx.fileSystem().writeFileBlocking(targetModel, Buffer.buffer(camelModel.toString()));
// generate API
- StringBuilder camelApi = new StringBuilder();
- camelApi.append(
- "/**\n" +
- " * Generated by karavan build tools - do NOT edit this file!\n" +
- " */\n");
- camelApi.append("import {\n");
- camelApi.append(" CamelElement, \n");
- camelApi.append(" ProcessorStep, \n");
- camelApi.append(" ProcessorStepMeta, \n");
- camelApi.append(" FromStep, \n");
- camelApi.append(" Expression, \n");
- processors.values().forEach(s -> {
- if (s.equalsIgnoreCase("otherwise")) {
- camelApi.append(" Otherwise, \n");
- } else if (s.equalsIgnoreCase("when")) {
- camelApi.append(" When, \n");
- } else {
- camelApi.append(" ").append(s).append("Step, \n");
- }
- });
- camelApi.append("} from '../model/CamelModel' \n\n");
- camelApi.append("import * as dataFormat from '../model/CamelDataFormat'; \n\n");
-
- camelApi.append("export class CamelApi { \n\n");
-
- camelApi.append(getTemplateFile("CamelApi.camelize.tx").concat("\n").concat("\n"));
-
- camelApi.append(
- " static createStep = (name: string, body: any, clone: boolean = false): CamelElement => {\n" +
- " const newBody = CamelApi.camelizeBody(name, body, clone);\n" +
- " switch (name){\n" +
- " case 'from': return CamelApi.createFrom(newBody);\n" +
- " case 'expression': return CamelApi.createExpression(newBody);\n");
- processors.values().forEach(s ->
- camelApi.append(" case '").append(deCapitalize(s)).append("': return CamelApi.create").append(capitalize(s)).append("(newBody);\n"));
- camelApi.append(" default: return new ProcessorStep('');\n");
- camelApi.append(" }\n");
- camelApi.append(" }\n");
-
-
- camelApi.append(
- " static createExpression = (element: any): Expression => {\n" +
- " return new Expression({...element})\n" +
- " }\n");
- camelApi.append(createCreateFunction("from", models.get("from"), "uri"));
- processors.values().forEach((model) -> camelApi.append(createCreateFunction(model, models.get(model), propertyToMapStrings.get(model))));
-
-
- camelApi.append(
- " static createSteps = (elements: any[] | undefined): ProcessorStep[] => {\n" +
- " const result: ProcessorStep[] = []\n" +
- " if (elements !== undefined){\n" +
- " elements.forEach(e => {\n" +
- " const stepName = Object.keys(e).filter(key => !['uuid', 'dslName'].includes(key))[0];\n" +
- " result.push(CamelApi.createStep(CamelApi.camelizeName(stepName, '-', true), e));\n" +
- " })\n" +
- " }\n" +
- " return result\n" +
- " }\n\n");
-
-
- camelApi.append(
- " static elementFromStep = (step: CamelElement): CamelElement => {\n" +
- " switch (step.dslName){\n" +
- " case 'fromStep' : return (step as FromStep).from\n");
- processors.values().forEach(s -> {
- if (s.equalsIgnoreCase("otherwise")) {
- camelApi.append(" case 'otherwise': return (step as Otherwise)\n");
- } else if (s.equalsIgnoreCase("when")) {
- camelApi.append(" case 'when': return (step as When)\n");
- } else {
- camelApi.append(" case '").append(deCapitalize(s)).append("Step': return (step as ").append(capitalize(s)).append("Step).").append(deCapitalize(s)).append("\n");
- }
- });
- camelApi.append(
- " default : return new CamelElement('')\n" +
- " }\n" +
- " }\n\n");
-
- // addStep functions
- camelApi.append(
- " static addStep = (steps: ProcessorStep[], step: ProcessorStep, parentId: string, position?: number): ProcessorStep[] => {\n" +
- " const result: ProcessorStep[] = [];\n" +
- " steps.forEach(el => {\n" +
- " switch (el.dslName) {\n");
- models.entrySet().forEach(s -> {
- String name = deCapitalize(s.getKey());
- String stepClass = capitalize(s.getKey()).concat("Step");
- String stepField = deCapitalize(s.getKey()).concat("Step");
-
- if (name.equals("choice")) {
- camelApi.append(getTemplateFile("CamelApi.addStep.choiceStep.tx").concat("\n"));
- } else if (name.equals("otherwise")) {
- camelApi.append(getTemplateFile("CamelApi.addStep.otherwise.tx").concat("\n"));
- } else if (name.equals("when")) {
- camelApi.append(getTemplateFile("CamelApi.addStep.when.tx").concat("\n"));
- } else if (s.getValue().stream().filter(e -> e.name.equals("steps")).count() > 0) {
- camelApi.append(String.format(
- " case '%1$s':\n" +
- " const %3$sChildren = (el as %2$s).%3$s?.steps || [];\n" +
- " if (el.uuid === parentId) position !== undefined ? %3$sChildren.splice(position, 0, step) : %3$sChildren.push(step);\n" +
- " else (el as %2$s).%3$s.steps = CamelApi.addStep(%3$sChildren, step, parentId, position);\n" +
- " break;\n",
- stepField, stepClass, name));
- }
- });
- camelApi.append(
- " }\n" +
- " result.push(el);\n" +
- " })\n" +
- " return result;\n" +
- " }\n\n");
-
-
- // deleteStep functions
- camelApi.append(
- " static deleteStep = (steps: ProcessorStep[] | undefined, uuidToDelete: string): ProcessorStep[] => {\n" +
- " const result: ProcessorStep[] = []\n" +
- " if (steps !== undefined){\n" +
- " steps.forEach(step => {\n" +
- " if (step.uuid !== uuidToDelete){\n" +
- " switch (step.dslName){\n");
- models.entrySet().forEach(s -> {
- String name = deCapitalize(s.getKey());
- String stepClass = capitalize(s.getKey()).concat("Step");
- String stepField = deCapitalize(s.getKey()).concat("Step");
- if (name.equals("otherwise")) {
- camelApi.append(" case 'otherwise': (step as Otherwise).steps = CamelApi.deleteStep((step as Otherwise).steps, uuidToDelete); break;\n");
- } else if (name.equals("when")) {
- camelApi.append(" case 'when': (step as When).steps = CamelApi.deleteStep((step as When).steps, uuidToDelete); break;\n");
- } else if (name.equals("choice")) {
- camelApi.append(" case 'choiceStep':\n" +
- " const otherwise = (step as ChoiceStep).choice.otherwise;\n" +
- " if (otherwise && otherwise.uuid === uuidToDelete) {\n" +
- " (step as ChoiceStep).choice.otherwise = undefined;\n" +
- " } else if (otherwise && otherwise.uuid !== uuidToDelete) {\n" +
- " otherwise.steps = CamelApi.deleteStep(otherwise.steps, uuidToDelete);\n" +
- " (step as ChoiceStep).choice.otherwise = otherwise;\n" +
- " }\n" +
- " (step as ChoiceStep).choice.when = CamelApi.deleteWhen((step as ChoiceStep).choice.when, uuidToDelete);\n" +
- " break;\n");
- } else if (s.getValue().stream().filter(e -> e.name.equals("steps")).count() > 0) {
- camelApi.append(String.format(" case '%s': (step as %s).%s.steps = CamelApi.deleteStep((step as %s).%s.steps, uuidToDelete); break;\n",
- stepField, stepClass, name, stepClass, name));
- }
- });
- camelApi.append(
- " }\n" +
- " result.push(step);\n" +
- " }\n" +
- " })\n" +
- " }\n" +
- " return result\n" +
- " }\n\n");
- camelApi.append(getTemplateFile("CamelApi.deleteWhen.tx").concat("\n\n"));
-
-
- // findStep functions
- camelApi.append(getTemplateFile("CamelApi.findStep.header.tx").concat("\n"));
- models.entrySet().forEach(s -> {
- String name = deCapitalize(s.getKey());
- String stepClass = capitalize(s.getKey()).concat("Step");
- String stepField = deCapitalize(s.getKey()).concat("Step");
-
- if (name.equals("choice")) {
- camelApi.append(getTemplateFile("CamelApi.findStep.choiceStep.tx").concat("\n"));
- } else if (name.equals("otherwise")) {
- camelApi.append(getTemplateFile("CamelApi.findStep.otherwise.tx").concat("\n"));
- } else if (name.equals("when")) {
- camelApi.append(getTemplateFile("CamelApi.findStep.when.tx").concat("\n"));
- } else if (s.getValue().stream().filter(e -> e.name.equals("steps")).count() > 0) {
- camelApi.append(String.format(
- " case '%1$s':\n" +
- " result = CamelApi.findStep((step as %2$s).%3$s.steps, uuid, step.uuid, result);\n" +
- " if (result?.pathUuids !== undefined && result?.pathUuids.length > 0) result.pathUuids.push(step.uuid);\n" +
- " break;\n",
- stepField, stepClass, name));
- }
- });
- camelApi.append(getTemplateFile("CamelApi.findStep.footer.tx").concat("\n\n"));
-
- // Expression language finder
- camelApi.append(" static getExpressionLanguage = (init?: Partial<Expression>): string | undefined => {\n");
- models.get("expression").forEach(el -> {
- if (!el.name.equals("language"))
- camelApi.append(String.format(" if (init?.%s) return '%s'\n", el.name, el.name));
- });
- camelApi.append(" return undefined;\n");
- camelApi.append(" }\n");
-
- camelApi.append("}\n").append(System.lineSeparator());
+ String api = new CamelApiGenerator().generate(models, processors, propertyToMapStrings);
+ vertx.fileSystem().writeFileBlocking(targetApi, Buffer.buffer(api));
- vertx.fileSystem().writeFileBlocking(targetApi, Buffer.buffer(camelApi.toString()));
+ // Generate CamelYamlStepApi
+ String code = new CamelYamlStepsGenerator().generate(models, processors, propertyToMapStrings);
+ vertx.fileSystem().writeFileBlocking(camelYamlSteps, Buffer.buffer(code));
// Generate Camel Models Metadata
StringBuilder metadata = new StringBuilder(readFileText(metadataTemplate));
@@ -312,67 +122,6 @@ public final class CamelModelGenerator extends AbstractGenerator {
writeFileText(targetMetadata, metadata.toString());
}
- private String createCreateFunction(String name, List<ElementProp> elProps, String propertyToMapStrings) {
- if (name.equalsIgnoreCase("otherwise")) {
- return getTemplateFile("CamelApi.createOtherwise.tx").concat("\n\n");
- } else if (name.equalsIgnoreCase("when")) {
- return getTemplateFile("CamelApi.createWhen.tx").concat("\n\n");
- } else if (name.equalsIgnoreCase("choice")) {
- return getTemplateFile("CamelApi.createChoice.tx").concat("\n\n");
- }
- String stepClass = capitalize(name).concat("Step");
- String stepField = deCapitalize(name).concat("Step");
- String elementName = deCapitalize(name);
- String funcName = "create".concat(capitalize(name));
- StringBuilder f = new StringBuilder();
- f.append(String.format(" static %s = (element: any): %s => {\n", funcName, stepClass));
- if (stepClass.equals("ToStep") || stepClass.equals("TodStep")) {
- f.append(String.format(" if (typeof element.%1$s !== 'object') element.%1$s = {uri: element.%1$s};\n", elementName));
- }
- // for oneOf string or object Definitions
- if (propertyToMapStrings != null){
- String p = deCapitalize(camelize(propertyToMapStrings, "-"));
- f.append(String.format(" if (element && element.%1$s && typeof element.%1$s === 'string') element.%1$s = {%2$s: element.%1$s};\n", elementName, p));
- }
- f.append(String.format(" const %1$s = element ? new %2$s({...element.%3$s}) : new %2$s();\n", stepField, stepClass, elementName));
- elProps.stream().forEach(e -> {
- if (e.name.equals("steps")) {
- f.append(String.format(" %s.%s.steps = CamelApi.createSteps(element?.%s?.steps);\n", stepField, elementName, elementName));
- } else if (e.isArray && e.isArrayTypeClass) {
- f.append(String.format(" %1$s.%2$s.%3$s = element && element?.%2$s ? element?.%2$s?.%3$s.map((x:any) => CamelApi.create%4$s(x)) :[];\n", stepField, elementName, e.name, e.arrayType));
- } else if (e.name.equalsIgnoreCase("expression")) {
- f.append(String.format(" const implicitExpression = CamelApi.getExpressionLanguage(element.%s);\n", elementName));
- f.append(String.format(" if (implicitExpression){\n"));
- f.append(String.format(" %1$s.%2$s.expression = new Expression({[implicitExpression]: element.%2$s[implicitExpression]});\n", stepField, elementName));
- f.append(String.format(" delete (%1$s.%2$s as any)[implicitExpression];\n", stepField, elementName));
- f.append(String.format(" } else {\n"));
- f.append(String.format(" %1$s.%2$s.expression = CamelApi.createExpression(element?.%2$s?.expression);\n", stepField, elementName));
- f.append(String.format(" }\n"));
- } else if (e.typeCode.startsWith("dataFormat.")) {
- String temp = " if (element.%3$s?.%1$s !== undefined) %2$s.%3$s.%1$s = new %4$s(element.%3$s.%1$s);\n";
- f.append(String.format(temp, e.name, stepField, elementName, e.typeCode));
- } else if (e.isObject) {
- f.append(String.format(" %s.%s.%s = CamelApi.create%s(element?.%s?.%s);\n", stepField, elementName, e.name, e.type, elementName, e.name));
- }
- });
- f.append(String.format(" %s.uuid = element?.uuid ? element.uuid : %s.uuid;\n", stepField, stepField));
- f.append(String.format(" return %s;\n", stepField));
- f.append(" }\n\n");
- return f.toString();
- }
-
- private String createCamelElements(Map<String, String> processors) {
- StringBuilder camelElements = new StringBuilder();
- camelElements.append("export const CamelElements: string[] = [").append(System.lineSeparator());
- camelElements.append("'").append("from").append("',").append(System.lineSeparator());
- camelElements.append("'").append("expression").append("',").append(System.lineSeparator());
- processors.values().stream().forEach(s -> {
- camelElements.append("'").append(deCapitalize(s)).append("',").append(System.lineSeparator());
- });
- camelElements.append("]").append(System.lineSeparator());
- return camelElements.toString();
- }
-
private List<ElementProp> generateElementProp(String name, JsonObject properties, JsonObject definitions, Map<String, String> processors) {
String modelName = deCapitalize(name.equals("Tod") ? "toD" : name);
String json = getMetaModel(modelName);
@@ -401,10 +150,10 @@ public final class CamelModelGenerator extends AbstractGenerator {
String arrayTypeClass = getArrayTypeClass(properties.getJsonObject(attr));
String arrayType = processors.get(arrayTypeClass);
if (arrayType != null) {
- String typeCode = propName.equals("when") ? getTypeCode(type, arrayType) : getTypeCode(type, arrayType.concat("Step"));
+ String typeCode = propName.equals("when") ? getTypeCode(type, arrayType) : getTypeCode(type, arrayType);
props.add(new ElementProp(propName, type, false, true, true, arrayType, false, typeCode));
} else if (arrayTypeClass.equals("org.apache.camel.model.ProcessorDefinition")) {
- props.add(new ElementProp(propName, type, false, true, true, arrayType, true, getTypeCode(type, "ProcessorStep")));
+ props.add(new ElementProp(propName, type, false, true, true, arrayType, true, getTypeCode(type, "CamelElement")));
}
} else if (type.equals("array") && !isArrayTypeIsClass(properties.getJsonObject(attr))) {
String arrayType = getArrayType(properties.getJsonObject(attr));
@@ -436,19 +185,6 @@ public final class CamelModelGenerator extends AbstractGenerator {
return props;
}
- private String generateStepCode(String name) {
- StringBuilder element = new StringBuilder();
- element.append("export class ").append(capitalize(name)).append("Step extends ProcessorStep {").append(System.lineSeparator());
- element.append(getTabs(1)).append(deCapitalize(name)).append(": ").append(capitalize(name)).append(" = new ").append(capitalize(name)).append("()").append(System.lineSeparator());
- element.append(System.lineSeparator());
- element.append(getTabs(1)).append("public constructor(init?: Partial<").append(capitalize(name)).append(">) {").append(System.lineSeparator());
- element.append(getTabs(2)).append("super('").append(deCapitalize(name)).append("Step')").append(System.lineSeparator());
- element.append(getTabs(2)).append("Object.assign(this, {").append(deCapitalize(name)).append(": new ").append(capitalize(name)).append("({...init})})").append(System.lineSeparator());
- element.append(getTabs(1)).append("}").append(System.lineSeparator());
- element.append("}").append(System.lineSeparator());
- return element.toString();
- }
-
private String generateElementCode(String name, List<ElementProp> elementProps) {
StringBuilder element = new StringBuilder();
element.append("export class ").append(capitalize(name)).append(" extends CamelElement { \n");
@@ -625,15 +361,6 @@ public final class CamelModelGenerator extends AbstractGenerator {
}
}
- public String getTemplateFile(String name) {
- try {
- InputStream inputStream = CamelModelGenerator.class.getClassLoader().getResourceAsStream(name);
- String data = new BufferedReader(new InputStreamReader(inputStream))
- .lines().collect(Collectors.joining(System.getProperty("line.separator")));
- return data;
- } catch (Exception e) {
- return null;
- }
- }
+
}
diff --git a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelYamlStepsGenerator.java b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelYamlStepsGenerator.java
new file mode 100644
index 0000000..f4cbacb
--- /dev/null
+++ b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelYamlStepsGenerator.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.karavan.generator;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public final class CamelYamlStepsGenerator extends AbstractGenerator {
+
+ public String generate(Map<String, List<ElementProp>> models, Map<String, String> processors, Map<String, String> propertyToMapStrings){
+ StringBuilder camelApi = new StringBuilder();
+ camelApi.append(
+ "/**\n" +
+ " * Generated by karavan build tools - do NOT edit this file!\n" +
+ " */\n");
+ camelApi.append("import {\n");
+ camelApi.append(" CamelElement, \n");
+ camelApi.append(" From, \n");
+ camelApi.append(" Expression, \n");
+ processors.values().forEach(s -> {
+ if (s.equalsIgnoreCase("otherwise")) {
+ camelApi.append(" Otherwise, \n");
+ } else if (s.equalsIgnoreCase("when")) {
+ camelApi.append(" When, \n");
+ } else {
+ camelApi.append(" ").append(s).append(",\n");
+ }
+ });
+ camelApi.append("} from '../model/CamelModel' \n");
+ camelApi.append("import * as dataFormat from '../model/CamelDataFormat'; \n");
+ camelApi.append("import {CamelUtil} from \"./CamelUtil\"; \n\n");
+
+ camelApi.append("export class CamelYamlStep { \n\n");
+
+ camelApi.append(
+ " static readStep = (name: string, body: any, clone: boolean = false): CamelElement => {\n" +
+ " const newBody = CamelUtil.camelizeBody(name, body, clone);\n" +
+ " switch (name){\n" +
+ " case 'from': return CamelYamlStep.readFrom(newBody);\n" +
+ " case 'expression': return CamelYamlStep.readExpression(newBody);\n");
+ processors.values().forEach(s ->
+ camelApi.append(" case '").append(deCapitalize(s)).append("': return CamelYamlStep.read").append(capitalize(s)).append("(newBody);\n"));
+ camelApi.append(" default: return new CamelElement('');\n");
+ camelApi.append(" }\n");
+ camelApi.append(" }\n");
+
+
+ camelApi.append(
+ " static readExpression = (element: any): Expression => {\n" +
+ " return new Expression({...element})\n" +
+ " }\n");
+ camelApi.append(createCreateFunction("from", models.get("from"), "uri"));
+
+ processors.values().forEach((model) -> camelApi.append(createCreateFunction(model, models.get(model), propertyToMapStrings.get(model))));
+
+
+ camelApi.append(
+ " static readSteps = (elements: any[] | undefined): CamelElement[] => {\n" +
+ " const result: CamelElement[] = []\n" +
+ " if (elements !== undefined){\n" +
+ " elements.forEach(e => {\n" +
+ " const stepName = Object.keys(e).filter(key => !['uuid', 'dslName'].includes(key))[0];\n" +
+ " result.push(CamelYamlStep.readStep(CamelUtil.camelizeName(stepName, '-', true), e));\n" +
+ " })\n" +
+ " }\n" +
+ " return result\n" +
+ " }\n\n");
+
+
+ // Expression language finder
+ camelApi.append(" static readExpressionLanguage = (init?: Partial<Expression>): string | undefined => {\n");
+ models.get("expression").forEach(el -> {
+ if (!el.name.equals("language"))
+ camelApi.append(String.format(" if (init?.%s) return '%s'\n", el.name, el.name));
+ });
+ camelApi.append(" return undefined;\n");
+ camelApi.append(" }\n");
+
+ camelApi.append("}\n").append(System.lineSeparator());
+
+ return camelApi.toString();
+ }
+
+ private String createCreateFunction(String name, List<ElementProp> elProps, String propertyToMapStrings) {
+ if (name.equalsIgnoreCase("otherwise")) {
+ return getTemplateFile("CamelYamlStep.readOtherwise.tx").concat("\n\n");
+ } else if (name.equalsIgnoreCase("when")) {
+ return getTemplateFile("CamelYamlStep.readWhen.tx").concat("\n\n");
+ } else if (name.equalsIgnoreCase("choice")) {
+ return getTemplateFile("CamelYamlStep.readChoice.tx").concat("\n\n");
+ }
+ String stepClass = capitalize(name);
+ String stepField = deCapitalize(name);
+ String elementName = deCapitalize(name);
+ String funcName = "read".concat(capitalize(name));
+ StringBuilder f = new StringBuilder();
+ f.append(String.format(" static %s = (element: any): %s => {\n", funcName, stepClass));
+ if (stepClass.equals("To") || stepClass.equals("Tod")) {
+ f.append(String.format(" if (typeof element.%1$s !== 'object') element.%1$s = {uri: element.%1$s};\n", elementName));
+ }
+ // for oneOf string or object Definitions
+ if (propertyToMapStrings != null){
+ String p = deCapitalize(camelize(propertyToMapStrings, "-"));
+ f.append(String.format(" if (element && element.%1$s && typeof element.%1$s === 'string') element.%1$s = {%2$s: element.%1$s};\n", elementName, p));
+ }
+ f.append(String.format(" const %1$s = element ? new %2$s({...element.%3$s}) : new %2$s();\n", stepField, stepClass, elementName));
+ elProps.stream().forEach(e -> {
+ if (e.name.equals("steps")) {
+ f.append(String.format(" %1$s.steps = CamelYamlStep.readSteps(element?.%2$s?.steps);\n", stepField, elementName));
+ } else if (e.isArray && e.isArrayTypeClass) {
+ f.append(String.format(" %1$s.%3$s = element && element?.%2$s ? element?.%2$s?.%3$s.map((x:any) => CamelYamlStep.read%4$s(x)) :[];\n", stepField, elementName, e.name, e.arrayType));
+ } else if (e.name.equalsIgnoreCase("expression")) {
+ f.append(String.format(" const implicitExpression = CamelYamlStep.readExpressionLanguage(element.%s);\n", elementName));
+ f.append(String.format(" if (implicitExpression){\n"));
+ f.append(String.format(" %1$s.expression = new Expression({[implicitExpression]: element.%2$s[implicitExpression]});\n", stepField, elementName));
+ f.append(String.format(" delete (%1$s as any)[implicitExpression];\n", stepField));
+ f.append(String.format(" } else {\n"));
+ f.append(String.format(" %1$s.expression = CamelYamlStep.readExpression(element?.%2$s?.expression);\n", stepField, elementName));
+ f.append(String.format(" }\n"));
+ } else if (e.typeCode.startsWith("dataFormat.")) {
+ String temp = " if (element.%3$s?.%1$s !== undefined) %2$s.%1$s = new %4$s(element.%3$s.%1$s);\n";
+ f.append(String.format(temp, e.name, stepField, elementName, e.typeCode));
+ } else if (e.isObject) {
+ f.append(String.format(" %s.%s = CamelYamlStep.read%s(element?.%s?.%s);\n", stepField, e.name, e.type, elementName, e.name));
+ }
+ });
+ f.append(String.format(" %s.uuid = element?.uuid ? element.uuid : %s.uuid;\n", stepField, stepField));
+ f.append(String.format(" return %s;\n", stepField));
+ f.append(" }\n\n");
+ return f.toString();
+ }
+
+
+ public String getTemplateFile(String name) {
+ try {
+ InputStream inputStream = CamelYamlStepsGenerator.class.getClassLoader().getResourceAsStream(name);
+ String data = new BufferedReader(new InputStreamReader(inputStream))
+ .lines().collect(Collectors.joining(System.getProperty("line.separator")));
+ return data;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/karavan-generator/src/main/resources/CamelApi.addStep.choiceStep.tx b/karavan-generator/src/main/resources/CamelApi.addStep.choiceStep.tx
index 0c5c408..49375b3 100644
--- a/karavan-generator/src/main/resources/CamelApi.addStep.choiceStep.tx
+++ b/karavan-generator/src/main/resources/CamelApi.addStep.choiceStep.tx
@@ -1,20 +1,20 @@
- case 'choiceStep':
- const choiceChildren = (el as ChoiceStep).choice?.when || [];
+ case 'choice':
+ const choiceChildren = (el as Choice).when || [];
if (el.uuid === parentId && step.dslName === 'when') {
choiceChildren.push(step as When);
- (el as ChoiceStep).choice.when = choiceChildren;
- } else if (el.uuid === parentId && step.dslName === 'otherwise' && !(el as ChoiceStep).choice.otherwise) {
- (el as ChoiceStep).choice.otherwise = step;
+ (el as Choice).when = choiceChildren;
+ } else if (el.uuid === parentId && step.dslName === 'otherwise' && !(el as Choice).otherwise) {
+ (el as Choice).otherwise = step;
} else {
- (el as ChoiceStep).choice.when = CamelApi.addStep(choiceChildren, step, parentId, position) as When[];
- const otherwise = (el as ChoiceStep).choice.otherwise;
+ (el as Choice).when = CamelApi.addStep(choiceChildren, step, parentId, position) as When[];
+ const otherwise = (el as Choice).otherwise;
if (otherwise?.uuid === parentId){
otherwise.steps = otherwise.steps ? [...otherwise.steps] : [];
otherwise.steps.push(step);
- (el as ChoiceStep).choice.otherwise = otherwise
+ (el as Choice).otherwise = otherwise
} else if (otherwise && otherwise.steps && otherwise.steps.length > 0){
otherwise.steps = CamelApi.addStep(otherwise.steps, step, parentId, position);
- (el as ChoiceStep).choice.otherwise = otherwise;
+ (el as Choice).otherwise = otherwise;
}
}
break;
diff --git a/karavan-generator/src/main/resources/CamelApi.camelize.tx b/karavan-generator/src/main/resources/CamelApi.camelize.tx
deleted file mode 100644
index bcdab9e..0000000
--- a/karavan-generator/src/main/resources/CamelApi.camelize.tx
+++ /dev/null
@@ -1,29 +0,0 @@
- static capitalizeName = (name: string) => {
- try {
- return name[0].toUpperCase() + name.substring(1);
- } catch (e) {
- return name;
- }
- };
-
- static camelizeName = (
- name: string,
- separator: string,
- firstSmall: boolean
- ) => {
- const res = name
- .split(separator)
- .map((value) => CamelApi.capitalizeName(value))
- .join("");
- return firstSmall ? res[0].toLowerCase() + res.substring(1) : res;
- };
-
- static camelizeBody = (name: string, body: any, clone: boolean): any => {
- if (body){
- const oldKey = Object.keys(body)[0];
- const key = CamelApi.camelizeName(oldKey, '-', true);
- return !clone && key === name ? {[key]: body[oldKey]} : body;
- } else {
- return {};
- }
- };
diff --git a/karavan-generator/src/main/resources/CamelApi.createChoice.tx b/karavan-generator/src/main/resources/CamelApi.createChoice.tx
index 8d72337..5b2ed05 100644
--- a/karavan-generator/src/main/resources/CamelApi.createChoice.tx
+++ b/karavan-generator/src/main/resources/CamelApi.createChoice.tx
@@ -1,9 +1,9 @@
- static createChoice = (element: any): ChoiceStep => {
- const choiceStep = element ? new ChoiceStep({...element.choice}) : new ChoiceStep();
- if (element?.choice?.otherwise !== undefined){
- choiceStep.choice.otherwise = CamelApi.createOtherwise(element?.choice?.otherwise);
+ static createChoice = (element: any): Choice => {
+ const choiceStep = element ? new Choice({...element}) : new Choice();
+ if (element?.otherwise !== undefined){
+ choiceStep.otherwise = CamelApi.createOtherwise(element?.otherwise);
}
- choiceStep.choice.when = element && element?.choice ? element?.choice?.when.map((x:any) => CamelApi.createWhen(x)) :[]
+ choiceStep.when = element && element?.when ? element?.when.map((x:any) => CamelApi.createWhen(x)) :[]
choiceStep.uuid = element?.uuid ? element.uuid : choiceStep.uuid
return choiceStep
}
diff --git a/karavan-generator/src/main/resources/CamelApi.findStep.choiceStep.tx b/karavan-generator/src/main/resources/CamelApi.findStep.choiceStep.tx
index b6c1ecf..571ff76 100644
--- a/karavan-generator/src/main/resources/CamelApi.findStep.choiceStep.tx
+++ b/karavan-generator/src/main/resources/CamelApi.findStep.choiceStep.tx
@@ -1,7 +1,7 @@
- case 'choiceStep':
- const o = (step as ChoiceStep).choice.otherwise;
- const w = (step as ChoiceStep).choice.when;
- const s: ProcessorStep[] = [];
+ case 'choice':
+ const o = (step as Choice).otherwise;
+ const w = (step as Choice).when;
+ const s: CamelElement[] = [];
if (o) s.push(o);
if (w) s.push(...w);
result = CamelApi.findStep(s, uuid, step.uuid, result);
diff --git a/karavan-generator/src/main/resources/CamelApi.findStep.footer.tx b/karavan-generator/src/main/resources/CamelApi.findStep.footer.tx
index 1b2d44c..a53bdd2 100644
--- a/karavan-generator/src/main/resources/CamelApi.findStep.footer.tx
+++ b/karavan-generator/src/main/resources/CamelApi.findStep.footer.tx
@@ -2,11 +2,11 @@
} else {
const paths: string[] = result?.pathUuids ? result?.pathUuids : [];
paths.push(step.uuid);
- result = new ProcessorStepMeta(step, parentUuid, index, paths);
+ result = new CamelElementMeta(step, parentUuid, index, paths);
break;
}
}
}
const paths: string[] = result?.pathUuids ? result?.pathUuids : [];
- return new ProcessorStepMeta(result?.step, result?.parentUuid, result?.position, result?.pathUuids);
+ return new CamelElementMeta(result?.step, result?.parentUuid, result?.position, result?.pathUuids);
}
\ No newline at end of file
diff --git a/karavan-generator/src/main/resources/CamelApi.findStep.header.tx b/karavan-generator/src/main/resources/CamelApi.findStep.header.tx
index 72d09db..f4cf184 100644
--- a/karavan-generator/src/main/resources/CamelApi.findStep.header.tx
+++ b/karavan-generator/src/main/resources/CamelApi.findStep.header.tx
@@ -1,6 +1,6 @@
- static findStep = (steps: ProcessorStep[] | undefined, uuid: string, parentUuid?: string, result?: ProcessorStepMeta): ProcessorStepMeta => {
+ static findStep = (steps: CamelElement[] | undefined, uuid: string, parentUuid?: string, result?: CamelElementMeta): CamelElementMeta => {
if (result?.step !== undefined) return result;
- if (result === undefined) result = new ProcessorStepMeta(undefined, parentUuid, undefined, []);
+ if (result === undefined) result = new CamelElementMeta(undefined, parentUuid, undefined, []);
if (steps !== undefined){
for (let index = 0, step; step = steps[index]; index++) {
if (step.uuid !== uuid) {
diff --git a/karavan-generator/src/main/resources/camel-model.template b/karavan-generator/src/main/resources/CamelModel.ts
similarity index 85%
rename from karavan-generator/src/main/resources/camel-model.template
rename to karavan-generator/src/main/resources/CamelModel.ts
index bd1102f..dade57e 100644
--- a/karavan-generator/src/main/resources/camel-model.template
+++ b/karavan-generator/src/main/resources/CamelModel.ts
@@ -14,7 +14,7 @@ export class Metadata {
}
export class Spec {
- flows: FromStep[] = [];
+ flows: From[] = [];
public constructor(init?: Partial<Spec>) {
Object.assign(this, init);
@@ -51,17 +51,14 @@ export class CamelElement {
}
}
-export class ProcessorStep extends CamelElement {
-}
-
-export class ProcessorStepMeta {
- step?: ProcessorStep
+export class CamelElementMeta {
+ step?: CamelElement
parentUuid?: string
position: number = 0;
pathUuids: string [] = [];
- constructor(step?: ProcessorStep, parentUuid?: string, position?: number, pathUuids?: string []) {
+ constructor(step?: CamelElement, parentUuid?: string, position?: number, pathUuids?: string []) {
this.step = step;
this.parentUuid = parentUuid;
this.position = position || 0;
diff --git a/karavan-generator/src/main/resources/CamelYamlStep.readChoice.tx b/karavan-generator/src/main/resources/CamelYamlStep.readChoice.tx
new file mode 100644
index 0000000..0d8649a
--- /dev/null
+++ b/karavan-generator/src/main/resources/CamelYamlStep.readChoice.tx
@@ -0,0 +1,9 @@
+ static readChoice = (element: any): Choice => {
+ const choiceStep = element ? new Choice({...element.choice}) : new Choice();
+ if (element?.choice?.otherwise !== undefined){
+ choiceStep.otherwise = CamelYamlStep.readOtherwise(element?.choice?.otherwise);
+ }
+ choiceStep.when = element && element?.choice && element?.choice?.when ? element?.choice?.when.map((x:any) => CamelYamlStep.readWhen(x)) :[]
+ choiceStep.uuid = element?.uuid ? element.uuid : choiceStep.uuid
+ return choiceStep
+ }
diff --git a/karavan-generator/src/main/resources/CamelYamlStep.readOtherwise.tx b/karavan-generator/src/main/resources/CamelYamlStep.readOtherwise.tx
new file mode 100644
index 0000000..28a2811
--- /dev/null
+++ b/karavan-generator/src/main/resources/CamelYamlStep.readOtherwise.tx
@@ -0,0 +1,6 @@
+ static readOtherwise = (element: any): Otherwise => {
+ const otherwise = element ? new Otherwise({...element}) : new Otherwise();
+ otherwise.steps = CamelYamlStep.readSteps(element?.steps);
+ if (element?.uuid) otherwise.uuid = element?.uuid;
+ return otherwise
+ }
diff --git a/karavan-generator/src/main/resources/CamelYamlStep.readWhen.tx b/karavan-generator/src/main/resources/CamelYamlStep.readWhen.tx
new file mode 100644
index 0000000..5734292
--- /dev/null
+++ b/karavan-generator/src/main/resources/CamelYamlStep.readWhen.tx
@@ -0,0 +1,7 @@
+ static readWhen = (element: any): When => {
+ const when = element ? new When({...element}) : new When()
+ when.expression = CamelYamlStep.readExpression(element?.expression)
+ when.steps = CamelYamlStep.readSteps(element?.steps)
+ when.uuid = element?.uuid ? element.uuid : when.uuid
+ return when
+ }