{
  "factory": {
    "id": "common-system-profile",
    "type": "entaxy.runtime.profile",
    "description": "Factory common-system-profile of entaxy.runtime.profile",
    "displayName": "System profile",
    "isAbstract": false
  },
  "entaxy.runtime.profile": {
  	"profileType": "SYSTEM"
  },
  "fields": {
		"__objectId": {
			"type": "String",
			"required": true,
			"isHidden": true,
			"defaultValue": {
				"@CALCULATED": {
					"expression": "${properties.systemName}",
					"targetPath": "$.objectId",
					"removeResolved": true,
					"lazy": false
				}
			}
		},  
		"systemName": {
			"displayName": "System Name",
			"type": "String",
			"required": true,
			"immutable": true,
			"group": "general",
			"@TYPEINFO": {
				"validation": {
					"rules": [
						{
							"length": {
								"min": 3
							}
						},
						{
							"content": {
								"regex": "^[a-zA-Z][a-zA-Z0-9-]*$",
								"errorMessage": "Value can contain only latin letters, numbers and hyphen and should start with a letter"
							}
						}
					]
				}
			}
		},
		"description": {
			"displayName": "Description",
			"type": "String",
			"group": "general"
		},
		"profileProperties": {
			"type": "Map",
			"required": true,
			"isHidden": true,
			"defaultValue": {
				"profile": {
					"@CALCULATED": {
						"expression": "${properties.systemName}",
						"lazy": true
					}
				}
			}
		},
		"in-flow-pre-route": {
			"displayName": "In-flow pre-route",
			"type": "xml:route",
			"required": true,
			"group": "in-flow",
			"@RESOURCE": {
				"_provider": "entaxy-file-internal",
				"endType": "String",
				"format": "base64",
				"preprocess":[
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:factories/common-system-profile/profile-pre-route.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					},
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:routes-common/common-components.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					}
					
				]
				
			},
			"defaultValue": {
				"@RESOURCE": {
					"provider": "entaxy-file-internal",
					"location": "factories/common-system-profile/in-flow-pre-route.xml",
					"endType": "String",
					"format": "base64"
				}
			},
			"config": {
				"scope": "public"
			}
		},
		"inFlowProcessResponse": {
			"displayName": "Process response",
			"type": "Boolean",
			"required": true,
			"group": "in-flow",
			"defaultValue": false		
		},
		"in-flow-response": {
			"displayName": "In-flow response",
			"type": "xml:route",
			"required": true,
			"group": "in-flow",
			"@RESOURCE": {
				"_provider": "entaxy-file-internal",
				"endType": "String",
				"format": "base64",
				"preprocess":[
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:factories/common-system-profile/profile-pre-route.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					},
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:routes-common/common-components.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					}
					
				]
				
			},
			"defaultValue": {
				"@RESOURCE": {
					"provider": "entaxy-file-internal",
					"location": "factories/common-system-profile/in-flow-response.xml",
					"endType": "String",
					"format": "base64"
				}
			},
			"config": {
				"scope": "public"
			}
		},		
		"out-flow-pre-route": {
			"displayName": "Out-flow pre-route",
			"type": "xml:route",
			"required": true,
			"group": "out-flow",
			"@RESOURCE": {
				"_provider": "entaxy-file-internal",
				"endType": "String",
				"format": "base64",
				"preprocess":[
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:factories/common-system-profile/profile-pre-route.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					},
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:routes-common/common-components.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					}
					
				]
				
			},
			"defaultValue": {
				"@RESOURCE": {
					"provider": "entaxy-file-internal",
					"location": "factories/common-system-profile/out-flow-pre-route.xml",
					"endType": "String",
					"format": "base64"
				}
			},
			"config": {
				"scope": "public"
			}
		},
		"outFlowProcessResponse": {
			"displayName": "Postprocess response",
			"type": "Boolean",
			"required": true,
			"group": "out-flow",
			"defaultValue": false		
		},
		"out-flow-response": {
			"displayName": "Out-flow postprocess",
			"type": "xml:route",
			"required": true,
			"group": "out-flow",
			"@RESOURCE": {
				"_provider": "entaxy-file-internal",
				"endType": "String",
				"format": "base64",
				"preprocess":[
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:factories/common-system-profile/profile-pre-route.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					},
					{
						"processor": "xslt",
						"source":"entaxy-file-internal:routes-common/common-components.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					}
					
				]
				
			},
			"defaultValue": {
				"@RESOURCE": {
					"provider": "entaxy-file-internal",
					"location": "factories/common-system-profile/out-flow-response.xml",
					"endType": "String",
					"format": "base64"
				}
			},
			"config": {
				"scope": "public"
			}
		},		
		"connector-selector": {
			"displayName": "Output connector selector",
			"type": "xml:route",
			"required": true,
			"group": "out-flow",
			"@RESOURCE": {
				"_provider": "entaxy-file-internal",
				"endType": "String",
				"format": "base64",
				"preprocess":[
					{
						"processor": "saxon",
						"source":"entaxy-file-internal:factories/common-system-profile/out-flow-connector-selector.xslt",
						"parameters": {
							"profileName": {				
								"@CALCULATED": {
									"expression": "${#OWNER#.properties.systemName}",
									"lazy": false
								}
							}
						}
					}
				]
				
			},
			"defaultValue": {
				"@RESOURCE": {
					"provider": "entaxy-file-internal",
					"location": "factories/common-system-profile/out-flow-connector-selector.xml",
					"endType": "String",
					"format": "base64"
				}
			},
			"config": {
				"scope": "public"
			}
		},
		/* TO_REMOVE */
		"useDefaultRoute": {
			"displayName": "Use Default Route",
			"type": "Boolean",
			"required": true,
			"isHidden": true,
			"defaultValue": true,
			"fixedValue": true,
			"group": "in-flow"
		},
		
		"defaultRouteContent": {
			"displayName": "Default profile route",
			"type": "xml:route",
			"required": true,
			"group": "in-flow",
			"defaultValue": {
				"@RESOURCE": {
					"provider": "entaxy-file-internal",
					"location": "factories/default-route-2/default-route.xml",
					"endType": "String",
					"format": "base64"
				}
			},
			"@FACADE": {
				"useFacade": true,
				"type": "String",
				"value": "Go to routes to view or edit this value"
			},
			"config": {
				"scope": "public"
			}
		},
		"defaultRoute": {
			"type": "entaxy.runtime.default-route",
			"isRef": true,
			/* actually there's no reference, but the object must be in a model */
			/* so while producing we must check the defaultRoute is found */
			"isBackRef": true,
			/* but only if useDefaultRoute is set to true */
			"condition": "${useDefaultRoute}",
			"required": true,
			"immutable": true,
			"defaultValue": {
				"type": "entaxy.runtime.default-route",
				"factoryId": "default-route-2",
				"properties": {
					"systemName": {
						"@CALCULATED": {
							"expression": "${#OWNER#.properties.systemName}",
							"lazy": false
						}	
					},
					"description": {
						"@CALCULATED": {
							"expression": "Default route for ${#OWNER#.properties.systemName}",
							"lazy": false
						}
					},
					"routeContent": {
						"@CALCULATED": {
							"expression": "${#OWNER_OF_TYPE:entaxy.runtime.profile#.properties.defaultRouteContent}",
							"lazy": false,
							"allowObjects": false
						}
					},
					"profileObjectType": {
						"@CALCULATED": {
							"expression": "${#OWNER_OF_TYPE:entaxy.runtime.profile#.#FACTORY#.factory.type}",
							"lazy": false,
							"allowObjects": false
						}
					}
				}
			}
			
		},
		"__legacyComponents": {
			"type": "entaxy.runtime.profile",
			"isRef": true,
			"required": true,
			"isHidden": true,
			"isRefByValueOnly": true,
			"@INTERNAL": true,
			"defaultValue": {
				"factoryId": "common-system-profile",
				"type": "entaxy.runtime.profile",
				"outputType": "legacy",
				"scope": "private",
				"properties": {
					"systemProfileName": {
						"@CALCULATED": {
							"expression": "${#OWNER#.properties.systemName}",
							"lazy": false
						}
					}
				}				
			}
		},
		"profileType": {
			"type": "String",
			"required": true,
			"isHidden": true,
			"defaultValue": {
				"@CALCULATED": {
					"expression": "${#FACTORY#.#TYPEINFO#.profileType}",
					"lazy": false
				}
			}
		},
		"##publish": {
			"defaultValue": {
				"profileType": {
					"@CALCULATED": {
						"expression": "${#FACTORY#.#TYPEINFO#.profileType}",
						"lazy": false
					}
				},
				"system": {
					"@CALCULATED": {
						"expression": "${properties.systemName}",
						"lazy": false
					}
				},
				"desc": {
					"@CALCULATED": {
						"expression": "${properties.description}",
						"lazy": false
					}
				}
			}
		}
  },
  "outputs": {
    "init": {
      "isDefault": true,
      "fields": {
      	"objectId": {
      		"isHidden": true
      	},
      	"__objectId": {},
		"systemName": {},
		"description": {},
		"useDefaultRoute": {},
		"defaultRoute": {
			"isHidden": true
		},
		"defaultRouteContent": {},
		"profileProperties": {},
		"in-flow-pre-route": {},
		"inFlowProcessResponse": {},
		"in-flow-response": {},
		"out-flow-pre-route": {},
		"outFlowProcessResponse": {},
		"out-flow-response": {},
		"connector-selector": {}, 
		"profileType": {},
		"__legacyComponents": {}	      
	  },
      "config": {
      	"configurable": false
      }
    },
    "legacy": {
    	"fields": {
    		"systemProfileName": {}
    	},
		"scopes": ["private"],
		"config": {
			"@SKIP_PUBLISH": {},
			"configurable": false
		}	
    }
  }
}