Java Code Examples for com.fasterxml.jackson.module.jsonSchema.types.ObjectSchema#setTitle()
The following examples show how to use
com.fasterxml.jackson.module.jsonSchema.types.ObjectSchema#setTitle() .
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: FhirMetadataRetrieval.java From syndesis with Apache License 2.0 | 6 votes |
private static String newPatchSpecification(Integer operationNumber) { final JsonSchemaFactory factory = new JsonSchemaFactory(); final ObjectSchema patchSchema = factory.objectSchema(); patchSchema.set$schema("http://json-schema.org/schema#"); patchSchema.setTitle("Patch"); patchSchema.putProperty("id", factory.stringSchema()); for (int i = 1; i <= operationNumber; i++) { final ObjectSchema operation = factory.objectSchema(); operation.putProperty("op", factory.stringSchema()); operation.putProperty("path", factory.stringSchema()); operation.putProperty("value", factory.stringSchema()); patchSchema.putProperty(String.valueOf(i), operation); } final String schema; try { schema = JsonUtils.writer().writeValueAsString(patchSchema); } catch (JsonProcessingException e) { throw new SyndesisServerException(e); } return schema; }
Example 2
Source File: GoogleSheetsMetaDataHelper.java From syndesis with Apache License 2.0 | 6 votes |
public static JsonSchema createSchema(String range, String majorDimension, boolean split, String ... columnNames) { ObjectSchema spec = new ObjectSchema(); spec.setTitle("VALUE_RANGE"); spec.putProperty("spreadsheetId", new JsonSchemaFactory().stringSchema()); RangeCoordinate coordinate = RangeCoordinate.fromRange(range); if (ObjectHelper.equal(RangeCoordinate.DIMENSION_ROWS, majorDimension)) { createSchemaFromRowDimension(spec, coordinate, columnNames); } else if (ObjectHelper.equal(RangeCoordinate.DIMENSION_COLUMNS, majorDimension)) { createSchemaFromColumnDimension(spec, coordinate); } if (split) { spec.set$schema(JSON_SCHEMA_ORG_SCHEMA); return spec; } else { ArraySchema arraySpec = new ArraySchema(); arraySpec.set$schema(JSON_SCHEMA_ORG_SCHEMA); arraySpec.setItemsSchema(spec); return arraySpec; } }
Example 3
Source File: SalesforceMetadataRetrieval.java From syndesis with Apache License 2.0 | 6 votes |
static ObjectSchema convertSalesforceGlobalObjectJsonToSchema(final JsonNode payload) { final Set<Object> allSchemas = new HashSet<>(); for (final JsonNode sobject : payload) { // generate SObject schema from description final ObjectSchema sobjectSchema = new ObjectSchema(); sobjectSchema.setId(JsonUtils.DEFAULT_ID_PREFIX + ":" + sobject.get("name").asText()); sobjectSchema.setTitle(sobject.get("label").asText()); allSchemas.add(sobjectSchema); } final ObjectSchema schema = new ObjectSchema(); schema.setOneOf(allSchemas); return schema; }
Example 4
Source File: MongoDBMetadataRetrieval.java From syndesis with Apache License 2.0 | 6 votes |
public static String buildFilterJsonSpecification(String filter) { final JsonSchemaFactory factory = new JsonSchemaFactory(); final ObjectSchema builderIn = new ObjectSchema(); List<String> parameters = FilterUtil.extractParameters(filter); builderIn.setTitle("Filter parameters"); for(String param:parameters){ builderIn.putProperty(param,factory.stringSchema()); } String jsonSpecification = null; try { jsonSpecification = MAPPER.writeValueAsString(builderIn); } catch (JsonProcessingException e) { LOGGER.error("Issue while processing filter parameters", e); } return jsonSpecification; }
Example 5
Source File: SalesforceMetadataRetrievalTest.java From syndesis with Apache License 2.0 | 5 votes |
ObjectSchema simpleObjectSchema(final String name, final String label) { final ObjectSchema objectSchema = new ObjectSchema(); objectSchema.setId(JsonUtils.DEFAULT_ID_PREFIX + ":" + name); objectSchema.setTitle(label); return objectSchema; }
Example 6
Source File: SqlMetadataRetrieval.java From syndesis with Apache License 2.0 | 4 votes |
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.StdCyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity"}) public SyndesisMetadata adaptForSql(final String actionId, final Map<String, Object> properties, final MetaData metadata) { final Map<String, List<PropertyPair>> enrichedProperties = new HashMap<>(); @SuppressWarnings("unchecked") final SqlStatementMetaData sqlStatementMetaData = (SqlStatementMetaData) metadata.getPayload(); if (sqlStatementMetaData != null) { enrichedProperties.put(QUERY, Collections.singletonList(new PropertyPair(sqlStatementMetaData.getSqlStatement()))); // build the input and output schemas final JsonSchema specIn; final ObjectSchema builderIn = new ObjectSchema(); builderIn.setTitle("SQL_PARAM_IN"); if (sqlStatementMetaData.isVerifiedBatchUpdateMode()) { ArraySchema arraySpec = new ArraySchema(); arraySpec.set$schema(JSON_SCHEMA_ORG_SCHEMA); arraySpec.setItemsSchema(builderIn); specIn = arraySpec; } else { builderIn.set$schema(JSON_SCHEMA_ORG_SCHEMA); specIn = builderIn; } for (SqlParam inParam: sqlStatementMetaData.getInParams()) { builderIn.putProperty(inParam.getName(), schemaFor(inParam.getJdbcType())); } final ObjectSchema builderOut = new ObjectSchema(); builderOut.setTitle("SQL_PARAM_OUT"); for (SqlParam outParam: sqlStatementMetaData.getOutParams()) { builderOut.putProperty(outParam.getName(), schemaFor(outParam.getJdbcType())); } final ArraySchema outputSpec = new ArraySchema(); outputSpec.set$schema(JSON_SCHEMA_ORG_SCHEMA); outputSpec.setItemsSchema(builderOut); try { DataShape.Builder inDataShapeBuilder = new DataShape.Builder().type(builderIn.getTitle()); if (builderIn.getProperties().isEmpty()) { inDataShapeBuilder.kind(DataShapeKinds.NONE); } else { inDataShapeBuilder.kind(DataShapeKinds.JSON_SCHEMA) .name("SQL Parameter") .description(String.format("Parameters of SQL [%s]", sqlStatementMetaData.getSqlStatement())) .specification(JsonUtils.writer().writeValueAsString(specIn)); if (specIn.isObjectSchema()) { inDataShapeBuilder.putMetadata(DataShapeMetaData.VARIANT, DataShapeMetaData.VARIANT_ELEMENT); } if (specIn.isArraySchema()) { inDataShapeBuilder.putMetadata(DataShapeMetaData.VARIANT, DataShapeMetaData.VARIANT_COLLECTION); } } DataShape.Builder outDataShapeBuilder = new DataShape.Builder().type(builderOut.getTitle()); if (builderOut.getProperties().isEmpty()) { outDataShapeBuilder.kind(DataShapeKinds.NONE); } else { outDataShapeBuilder.kind(DataShapeKinds.JSON_SCHEMA) .name("SQL Result") .description(String.format("Result of SQL [%s]", sqlStatementMetaData.getSqlStatement())) .putMetadata(DataShapeMetaData.VARIANT, DataShapeMetaData.VARIANT_COLLECTION) .specification(JsonUtils.writer().writeValueAsString(outputSpec)); } return new SyndesisMetadata(enrichedProperties, inDataShapeBuilder.build(), outDataShapeBuilder.build()); } catch (JsonProcessingException e) { throw new IllegalStateException(e); } } else { return new SyndesisMetadata(enrichedProperties, null, null); } }
Example 7
Source File: SqlMetadataRetrieval.java From syndesis with Apache License 2.0 | 4 votes |
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.StdCyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity"}) public SyndesisMetadata adaptForStoredSql(final String actionId, final Map<String, Object> properties, final MetaData metadata) { final Map<String, List<PropertyPair>> enrichedProperties = new HashMap<>(); // list of stored procedures in the database @SuppressWarnings("unchecked") final Map<String, StoredProcedureMetadata> procedureMap = (Map<String, StoredProcedureMetadata>) metadata.getPayload(); if (isPresentAndNonNull(properties, PATTERN) && FROM_PATTERN.equalsIgnoreCase(ConnectorOptions.extractOption(properties, PATTERN))) { enrichedProperties.put(PROCEDURE_NAME, obtainFromProcedureList(procedureMap)); } else { enrichedProperties.put(PROCEDURE_NAME, obtainToProcedureList(procedureMap)); } // metadata for the named procedure if (isPresentAndNonNull(properties, PROCEDURE_NAME)) { final List<PropertyPair> ppList = new ArrayList<>(); final String procedureName = ConnectorOptions.extractOption(properties, PROCEDURE_NAME); final StoredProcedureMetadata storedProcedure = procedureMap.get(procedureName); ppList.add(new PropertyPair(storedProcedure.getTemplate(), PROCEDURE_TEMPLATE)); enrichedProperties.put(PROCEDURE_TEMPLATE, ppList); // build the input and output schemas final ObjectSchema builderIn = new ObjectSchema(); builderIn.set$schema(JSON_SCHEMA_ORG_SCHEMA); builderIn.setTitle(procedureName + "_IN"); final ObjectSchema builderOut = new ObjectSchema(); builderOut.setTitle(procedureName + "_OUT"); builderOut.set$schema(JSON_SCHEMA_ORG_SCHEMA); if (storedProcedure.getColumnList() != null && !storedProcedure.getColumnList().isEmpty()) { for (final StoredProcedureColumn column : storedProcedure.getColumnList()) { if (column.getMode().equals(ColumnMode.IN) || column.getMode().equals(ColumnMode.INOUT)) { builderIn.putProperty(column.getName(), schemaFor(column.getJdbcType())); } if (column.getMode().equals(ColumnMode.OUT) || column.getMode().equals(ColumnMode.INOUT)) { builderOut.putProperty(column.getName(), schemaFor(column.getJdbcType())); } } } try { DataShape.Builder inDataShapeBuilder = new DataShape.Builder().type(builderIn.getTitle()); if (builderIn.getProperties().isEmpty()) { inDataShapeBuilder.kind(DataShapeKinds.NONE); } else { inDataShapeBuilder.kind(DataShapeKinds.JSON_SCHEMA) .name(procedureName + " Parameter") .description(String.format("Parameters of Stored Procedure '%s'", procedureName)) .specification(JsonUtils.writer().writeValueAsString(builderIn)); } DataShape.Builder outDataShapeBuilder = new DataShape.Builder().type(builderOut.getTitle()); if (builderOut.getProperties().isEmpty()) { outDataShapeBuilder.kind(DataShapeKinds.NONE); } else { outDataShapeBuilder.kind(DataShapeKinds.JSON_SCHEMA) .name(procedureName + " Return") .description(String.format("Return value of Stored Procedure '%s'", procedureName)) .putMetadata(DataShapeMetaData.VARIANT, DataShapeMetaData.VARIANT_ELEMENT) .specification(JsonUtils.writer().writeValueAsString(builderOut)); } return new SyndesisMetadata(enrichedProperties, inDataShapeBuilder.build(), outDataShapeBuilder.build()); } catch (JsonProcessingException e) { throw new IllegalStateException(e); } } return new SyndesisMetadata(enrichedProperties, null, null); }
Example 8
Source File: ODataMetaDataRetrieval.java From syndesis with Apache License 2.0 | 4 votes |
private static ObjectSchema createEntitySchema() { ObjectSchema entitySchema = new ObjectSchema(); entitySchema.setTitle("ODATA_ENTITY_PROPERTIES"); entitySchema.set$schema(JSON_SCHEMA_URI); return entitySchema; }
Example 9
Source File: KuduMetadataRetrieval.java From syndesis with Apache License 2.0 | 4 votes |
private static ObjectSchema createSpec(KuduMetaData kuduMetaData) { // build the input and output schemas ObjectSchema spec = new ObjectSchema(); spec.set$schema(JSON_SCHEMA_ORG_SCHEMA); spec.setTitle("KUDU_INSERT"); Map<String, Object> options = new HashMap<>(); options.put("host", kuduMetaData.getHost()); options.put("port", kuduMetaData.getPort()); KuduClient client = KuduSupport.createConnection(options); try { KuduTable table = client.openTable(kuduMetaData.getTableName()); Iterator<ColumnSchema> columns = table.getSchema().getColumns().iterator(); while (columns.hasNext()) { ColumnSchema column = columns.next(); switch (column.getType().getName()) { case "string": spec.putProperty(column.getName(), new JsonSchemaFactory().stringSchema()); break; case "bool": spec.putProperty(column.getName(), new JsonSchemaFactory().booleanSchema()); break; case "float": case "double": case "int8": case "int16": case "int32": case "int64": spec.putProperty(column.getName(), new JsonSchemaFactory().integerSchema()); break; default: throw new SyndesisServerException("The column schema type " + column.getType().getName() + " for column " + column.getName() + " is not supported at the moment"); } } } catch (KuduException e) { throw new SyndesisServerException("Unable to connect to kudu schema " + kuduMetaData.getTableName(), e); } return spec; }