public clone()

in ui/src/app/core-ui/static-properties/static-property-util.service.ts [87:185]


    public clone(val: StaticProperty) {
        let clone;
        const id = this.idGeneratorService.generatePrefixedId();
        if (val instanceof FreeTextStaticProperty) {
            clone = new FreeTextStaticProperty();
            clone.elementId = id;
            clone.value = val.value;
            clone.requiredDomainProperty = val.requiredDomainProperty;
        } else if (val instanceof FileStaticProperty) {
            clone = new FileStaticProperty();
            clone.elementId = id;
            clone.endpointUrl = val.endpointUrl;
            clone.locationPath = val.locationPath;
        } else if (val instanceof MappingPropertyUnary) {
            clone = new MappingPropertyUnary();
            clone.elementId = id;
            clone.requirementSelector = val.requirementSelector;
            clone.mapsFromOptions = val.mapsFromOptions;
            clone.propertyScope = val.propertyScope;
            clone.selectedProperty = val.selectedProperty;
        } else if (val instanceof MappingPropertyNary) {
            clone = new MappingPropertyNary();
            clone.elementId = id;
            clone.requirementSelector = val.requirementSelector;
            clone.mapsFromOptions = val.mapsFromOptions;
            clone.propertyScope = val.propertyScope;
            clone.selectedProperties = val.selectedProperties;
        } else if (val instanceof SecretStaticProperty) {
            clone = new SecretStaticProperty();
            clone.elementId = id;
            clone.value = val.value;
            clone.encrypted = val.encrypted;
        } else if (val instanceof ColorPickerStaticProperty) {
            clone = new ColorPickerStaticProperty();
            clone.id = id;
            clone.selectedProperty = val.selectedColor;
        } else if (val instanceof CodeInputStaticProperty) {
            clone = new CodeInputStaticProperty();
            clone.elementId = id;
            clone.codeTemplate = val.codeTemplate;
            clone.value = val.value;
            clone.language = val.language;
        } else if (val instanceof StaticPropertyGroup) {
            clone = new StaticPropertyGroup();
            clone.elementId = id;
            clone.staticProperties = val.staticProperties.map(elem =>
                this.clone(elem),
            );
            clone.showLabel = val.showLabel;
            clone.horizontalRendering = val.horizontalRendering;
        } else if (val instanceof StaticPropertyAlternatives) {
            clone = new StaticPropertyAlternatives();
            clone.elementId = id;
            clone.alternatives = val.alternatives.map(elem => this.clone(elem));
        } else if (val instanceof StaticPropertyAlternative) {
            clone = new StaticPropertyAlternative();
            clone.elementId = id;
            clone.selected = val.selected;
            clone.staticProperty = this.clone(val.staticProperty);
        } else if (val instanceof CollectionStaticProperty) {
            clone = new CollectionStaticProperty();
            clone.elementId = id;
            clone.staticPropertyTemplate = this.clone(
                val.staticPropertyTemplate,
            );
            clone.members = val.members.map(elem => this.clone(elem));
            clone.memberType = val.memberType;
        } else if (
            val instanceof RuntimeResolvableAnyStaticProperty ||
            val instanceof RuntimeResolvableOneOfStaticProperty
        ) {
            if (val instanceof RuntimeResolvableAnyStaticProperty) {
                clone = new RuntimeResolvableAnyStaticProperty();
            } else {
                clone = new RuntimeResolvableOneOfStaticProperty();
            }

            clone.elementId = id;
            clone.dependsOn = val.dependsOn;
            clone.options = val.options.map(option => this.cloneOption(option));
            clone.horizontalRendering = val.horizontalRendering;
        } else if (
            val instanceof AnyStaticProperty ||
            val instanceof OneOfStaticProperty
        ) {
            if (val instanceof AnyStaticProperty) {
                clone = new AnyStaticProperty();
            } else {
                clone = new OneOfStaticProperty();
            }

            clone.elementId = id;
            clone.options = val.options.map(option => this.cloneOption(option));
            clone.horizontalRendering = val.horizontalRendering;
        }
        clone = this.copyStaticPropertyProperty(val, clone);
        clone['@class'] = val['@class'];
        return clone;
    }