in ui/src/app/connect/services/transformation-rule.service.ts [53:151]
public makeTransformationRuleDescriptions(
originalSchema: EventSchema,
targetSchema: EventSchema,
): TransformationRuleDescriptionUnion[] {
let transformationRuleDescriptions: TransformationRuleDescriptionUnion[] =
[];
if (originalSchema == null || targetSchema == null) {
console.log('Old and new schema must be defined');
} else {
const addedTimestampProperty = this.getTimestampProperty(
targetSchema.eventProperties,
);
if (addedTimestampProperty) {
// add to old event schema for the case users moved the property to a nested property
originalSchema.eventProperties.push(addedTimestampProperty);
const timestampRuleDescription: AddTimestampRuleDescription =
new AddTimestampRuleDescription();
timestampRuleDescription['@class'] =
'org.apache.streampipes.model.connect.rules.value.AddTimestampRuleDescription';
timestampRuleDescription.runtimeKey =
addedTimestampProperty.runtimeName;
timestampRuleDescription.propertyScope =
addedTimestampProperty.propertyScope as PropertyScope;
transformationRuleDescriptions.push(timestampRuleDescription);
}
const staticValueProperties = this.getStaticValueProperties(
targetSchema.eventProperties,
);
for (const ep of staticValueProperties) {
this.pushCopyToOriginalSchemaIfNotExists(originalSchema, ep);
const rule = this.createAddValueTransformationRule(ep);
transformationRuleDescriptions.push(rule);
}
// Scale
transformationRuleDescriptions = transformationRuleDescriptions
.concat(
this.getRegexTransformationRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(
this.getCorrectionValueRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(
this.getRenameRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(
this.getCreateNestedRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(
this.getMoveRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(this.getDeleteRules(originalSchema, targetSchema))
.concat(
this.getUnitTransformRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(
this.getTimestampTransformRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
)
.concat(
this.getDatatypeTransformRules(
targetSchema.eventProperties,
originalSchema,
targetSchema,
),
);
return transformationRuleDescriptions;
}
}