File

src/app/shared/flo/support/utils.ts

Description

Utilities for Flo based graph editors.

Example

Index

Properties
Methods

Methods

Static decodeTextFromDSL
decodeTextFromDSL(dsl: string)
Parameters :
Name Type Optional Description
dsl string
Returns : string
Static encodeTextToDSL
encodeTextToDSL(text: string)
Parameters :
Name Type Optional Description
text string
Returns : string
Static isCodeTypeProperty
isCodeTypeProperty(metadata: Flo.ElementMetadata, property: string)
Parameters :
Name Type Optional Description
metadata Flo.ElementMetadata
property string
Returns : boolean
Static isUnresolved
isUnresolved(element: dia.Cell)
Parameters :
Name Type Optional Description
element dia.Cell
Returns : boolean

Properties

Static RX_JAVA_PROCESSOR_NAME
RX_JAVA_PROCESSOR_NAME:
Default value : rx-java-processor
Static RX_JAVA_PROCESSOR_SOURCE_TYPE
RX_JAVA_PROCESSOR_SOURCE_TYPE:
Default value : org.springframework.cloud.stream.app.transform.ProgrammableRxJavaProcessorProperties
Static SCRIPTABLE_TRANSFORM_NAME
SCRIPTABLE_TRANSFORM_NAME:
Default value : scriptable-transform
Static SCRIPTABLE_TRANSFORM_SOURCE_TYPE
SCRIPTABLE_TRANSFORM_SOURCE_TYPE:
Default value : org.springframework.cloud.stream.app.scriptable.transform.processor.ScriptableTransformProcessorProperties
import { Flo } from 'spring-flo';
import { dia } from 'jointjs';

/**
 * Utilities for Flo based graph editors.
 *
 * @author Alex Boyko
 */
export class Utils {

  static RX_JAVA_PROCESSOR_SOURCE_TYPE = 'org.springframework.cloud.stream.app.transform.ProgrammableRxJavaProcessorProperties';
  static SCRIPTABLE_TRANSFORM_SOURCE_TYPE =
    'org.springframework.cloud.stream.app.scriptable.transform.processor.ScriptableTransformProcessorProperties';

  static RX_JAVA_PROCESSOR_NAME = 'rx-java-processor';
  static SCRIPTABLE_TRANSFORM_NAME = 'scriptable-transform';

  static encodeTextToDSL(text: string): string {
    return '\"' + text.replace(/(?:\r\n|\r|\n)/g, '\\n').replace(/"/g, '""') + '\"';
  }

  static decodeTextFromDSL(dsl: string): string {
    if (dsl.charAt(0) === '\"' && dsl.charAt(dsl.length - 1) === '\"') {
      dsl = dsl.substr(1, dsl.length - 2);
    }
    return dsl.replace(/\\n/g, '\n').replace(/\"\"/g, '"');
  }

  static isCodeTypeProperty(metadata: Flo.ElementMetadata, property: string): boolean {
    const propertyLowerCase = property.toLowerCase();
    return (metadata.name === Utils.RX_JAVA_PROCESSOR_NAME
        && (propertyLowerCase === 'code' || propertyLowerCase === 'rxjava-processor.code'))
      || (metadata.name === Utils.SCRIPTABLE_TRANSFORM_NAME
        && (propertyLowerCase === 'script' || propertyLowerCase === 'scriptable-transformer.script'));
  }

  static isUnresolved(element: dia.Cell): boolean {
    return element.attr('metadata/metadata/unresolved');
  }

}

results matching ""

    No results matching ""