Java Code Examples for org.apache.camel.catalog.CamelCatalog#modelJSonSchema()
The following examples show how to use
org.apache.camel.catalog.CamelCatalog#modelJSonSchema() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CamelCatalogHelper.java From fabric8-forge with Apache License 2.0 | 6 votes |
/** * Checks whether the given value is matching the default value from the given model. * * @param modelName the model name * @param key the option key * @param value the option value * @return <tt>true</tt> if matching the default value, <tt>false</tt> otherwise */ public static boolean isModelDefaultValue(CamelCatalog camelCatalog, String modelName, String key, String value) { // use the camel catalog String json = camelCatalog.modelJSonSchema(modelName); if (json == null) { throw new IllegalArgumentException("Could not find catalog entry for model name: " + modelName); } List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("properties", json, true); if (data != null) { for (Map<String, String> propertyMap : data) { String name = propertyMap.get("name"); String defaultValue = propertyMap.get("defaultValue"); if (key.equals(name)) { return value.equalsIgnoreCase(defaultValue); } } } return false; }
Example 2
Source File: CamelCatalogHelper.java From fabric8-forge with Apache License 2.0 | 6 votes |
/** * Checks whether the given key is an expression kind * * @param modelName the model name * @param key the option key * @return <tt>true</tt> if the key is an expression type, <tt>false</tt> otherwise */ public static boolean isModelExpressionKind(CamelCatalog camelCatalog, String modelName, String key) { // use the camel catalog String json = camelCatalog.modelJSonSchema(modelName); if (json == null) { throw new IllegalArgumentException("Could not find catalog entry for model name: " + modelName); } List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("properties", json, true); if (data != null) { for (Map<String, String> propertyMap : data) { String name = propertyMap.get("name"); if (key.equals(name)) { return "expression".equals(propertyMap.get("kind")); } } } return false; }
Example 3
Source File: CamelCatalogHelper.java From fabric8-forge with Apache License 2.0 | 6 votes |
/** * Gets the java type of the given model * * @param modelName the model name * @return the java type */ public static String getModelJavaType(CamelCatalog camelCatalog, String modelName) { // use the camel catalog String json = camelCatalog.modelJSonSchema(modelName); if (json == null) { throw new IllegalArgumentException("Could not find catalog entry for model name: " + modelName); } List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("model", json, false); if (data != null) { for (Map<String, String> propertyMap : data) { String javaType = propertyMap.get("javaType"); if (javaType != null) { return javaType; } } } return null; }
Example 4
Source File: CamelCatalogHelper.java From fabric8-forge with Apache License 2.0 | 6 votes |
/** * Whether the EIP supports outputs * * @param modelName the model name * @return <tt>true</tt> if output supported, <tt>false</tt> otherwise */ public static boolean isModelSupportOutput(CamelCatalog camelCatalog, String modelName) { // use the camel catalog String json = camelCatalog.modelJSonSchema(modelName); if (json == null) { throw new IllegalArgumentException("Could not find catalog entry for model name: " + modelName); } List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("model", json, false); if (data != null) { for (Map<String, String> propertyMap : data) { String output = propertyMap.get("output"); if (output != null) { return "true".equals(output); } } } return false; }
Example 5
Source File: CamelCatalogHelper.java From fabric8-forge with Apache License 2.0 | 5 votes |
public static EipDto createEipDto(CamelCatalog camelCatalog, String modelName) { // use the camel catalog String json = camelCatalog.modelJSonSchema(modelName); if (json == null) { return null; } EipDto dto = new EipDto(); List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("model", json, false); for (Map<String, String> row : data) { if (row.get("name") != null) { dto.setName(row.get("name")); } else if (row.get("title") != null) { dto.setTitle(row.get("title")); } else if (row.get("description") != null) { dto.setDescription(row.get("description")); } else if (row.get("label") != null) { String labelText = row.get("label"); if (Strings.isNotBlank(labelText)) { dto.setTags(labelText.split(",")); } } else if (row.get("javaType") != null) { dto.setJavaType(row.get("javaType")); } } return dto; }