private void appendTypeDefinitions(final JsonGenerator json, final List<EdmTypeDefinition> typeDefinitions) throws SerializerException, IOException { for (EdmTypeDefinition definition : typeDefinitions) { json.writeObjectFieldStart(definition.getName()); json.writeStringField(KIND, definition.getKind().name()); json.writeStringField(UNDERLYING_TYPE, getFullQualifiedName(definition.getUnderlyingType())); // Facets if (definition.getMaxLength() != null) { json.writeStringField(MAX_LENGTH, "" + definition.getMaxLength()); } if (definition.getPrecision() != null) { json.writeStringField(PRECISION, "" + definition.getPrecision()); } if (definition.getScale() != null) { json.writeStringField(SCALE, "" + definition.getScale()); } if (definition.getSrid() != null) { json.writeStringField(SRID, "" + definition.getSrid()); } appendAnnotations(json, definition, null); json.writeEndObject(); } }
private void appendTypeDefinitions(final XMLStreamWriter writer, final List<EdmTypeDefinition> typeDefinitions) throws XMLStreamException { for (EdmTypeDefinition definition : typeDefinitions) { writer.writeStartElement(XML_TYPE_DEFINITION); writer.writeAttribute(XML_NAME, definition.getName()); writer.writeAttribute(XML_UNDERLYING_TYPE, getFullQualifiedName(definition.getUnderlyingType(), false)); // Facets if (definition.getMaxLength() != null) { writer.writeAttribute(XML_MAX_LENGTH, "" + definition.getMaxLength()); } if (definition.getPrecision() != null) { writer.writeAttribute(XML_PRECISION, "" + definition.getPrecision()); } if (definition.getScale() != null) { writer.writeAttribute(XML_SCALE, "" + definition.getScale()); } appendAnnotations(writer, definition); writer.writeEndElement(); } }
/** * Returns the primitive type's default class or the manually mapped class if present. * @param mapping * @param edmPrimitiveType * @return the java class to be used during deserialization */ private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType type) { final EdmPrimitiveType edmPrimitiveType = type.getKind() == EdmTypeKind.ENUM ? ((EdmEnumType) type).getUnderlyingType() : type .getKind() == EdmTypeKind.DEFINITION ? ((EdmTypeDefinition) type).getUnderlyingType() : type; return mapping == null || mapping.getMappedJavaClass() == null ? edmPrimitiveType.getDefaultType() : mapping .getMappedJavaClass(); }
/** * Returns the primitive type's default class or the manually mapped class if present. * @param mapping * @param edmPrimitiveType * @return the java class to be used during deserialization */ private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType type) { final EdmPrimitiveType edmPrimitiveType = type.getKind() == EdmTypeKind.ENUM ? ((EdmEnumType) type).getUnderlyingType() : type .getKind() == EdmTypeKind.DEFINITION ? ((EdmTypeDefinition) type).getUnderlyingType() : type; return mapping == null || mapping.getMappedJavaClass() == null ? edmPrimitiveType.getDefaultType() : mapping .getMappedJavaClass(); }
private void appendTypeDefinitions(final XMLStreamWriter writer, final List<EdmTypeDefinition> typeDefinitions) throws XMLStreamException { for (EdmTypeDefinition definition : typeDefinitions) { writer.writeStartElement(XML_TYPE_DEFINITION); writer.writeAttribute(XML_NAME, definition.getName()); writer.writeAttribute(XML_UNDERLYING_TYPE, getFullQualifiedName(definition.getUnderlyingType(), false)); // Facets if (definition.getMaxLength() != null) { writer.writeAttribute(XML_MAX_LENGTH, "" + definition.getMaxLength()); } if (definition.getPrecision() != null) { writer.writeAttribute(XML_PRECISION, "" + definition.getPrecision()); } if (definition.getScale() != null) { writer.writeAttribute(XML_SCALE, "" + definition.getScale()); } appendAnnotations(writer, definition); writer.writeEndElement(); } }
private void appendTypeDefinitions(final JsonGenerator json, final List<EdmTypeDefinition> typeDefinitions) throws SerializerException, IOException { for (EdmTypeDefinition definition : typeDefinitions) { json.writeObjectFieldStart(definition.getName()); json.writeStringField(KIND, definition.getKind().name()); json.writeStringField(UNDERLYING_TYPE, getFullQualifiedName(definition.getUnderlyingType())); // Facets if (definition.getMaxLength() != null) { json.writeStringField(MAX_LENGTH, "" + definition.getMaxLength()); } if (definition.getPrecision() != null) { json.writeStringField(PRECISION, "" + definition.getPrecision()); } if (definition.getScale() != null) { json.writeStringField(SCALE, "" + definition.getScale()); } if (definition.getSrid() != null) { json.writeStringField(SRID, "" + definition.getSrid()); } appendAnnotations(json, definition, null); json.writeEndObject(); } }
/** * Returns the primitive type's default class or the manually mapped class * if present. * * @param mapping * @param edmPrimitiveType * @return the java class to be used during deserialization */ private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType type) { final EdmPrimitiveType edmPrimitiveType = type.getKind() == EdmTypeKind.ENUM ? ((EdmEnumType) type).getUnderlyingType() : type.getKind() == EdmTypeKind.DEFINITION ? ((EdmTypeDefinition) type).getUnderlyingType() : type; return mapping == null || mapping.getMappedJavaClass() == null ? edmPrimitiveType.getDefaultType() : mapping.getMappedJavaClass(); }
private static boolean nextPrimitiveTypeValue(UriTokenizer tokenizer, final EdmPrimitiveType primitiveType, final boolean nullable) { final EdmPrimitiveType type = primitiveType instanceof EdmTypeDefinition ? ((EdmTypeDefinition) primitiveType).getUnderlyingType() : primitiveType; if (tokenizer.next(TokenKind.ParameterAliasName)) {
private static boolean nextPrimitiveTypeValue(UriTokenizer tokenizer, final EdmPrimitiveType primitiveType, final boolean nullable) { final EdmPrimitiveType type = primitiveType instanceof EdmTypeDefinition ? ((EdmTypeDefinition) primitiveType).getUnderlyingType() : primitiveType; if (tokenizer.next(TokenKind.ParameterAliasName)) {
private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType, final JsonNode jsonNode) throws DeserializerException { boolean valid = true; if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) { checkJsonTypeBasedOnPrimitiveType(propertyName, ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode); } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) { // Enum values must be strings. valid = jsonNode.isTextual(); } else { final String name = edmPrimitiveType.getName(); EdmPrimitiveTypeKind primKind; try { primKind = EdmPrimitiveTypeKind.valueOf(name); } catch (final IllegalArgumentException e) { throw new DeserializerException("Unknown Primitive Type: " + name, e, DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName); } valid = matchTextualCase(jsonNode, primKind) || matchNumberCase(jsonNode, primKind) || matchBooleanCase(jsonNode, primKind) || matchIEEENumberCase(jsonNode, primKind) || jsonNode.isObject() && name.startsWith("Geo"); } if (!valid) { throw new DeserializerException( "Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName); } }
private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType, final JsonNode jsonNode) throws DeserializerException { boolean valid = true; if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) { checkJsonTypeBasedOnPrimitiveType(propertyName, ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode); } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) { // Enum values must be strings. valid = jsonNode.isTextual(); } else { final String name = edmPrimitiveType.getName(); EdmPrimitiveTypeKind primKind; try { primKind = EdmPrimitiveTypeKind.valueOf(name); } catch (final IllegalArgumentException e) { throw new DeserializerException("Unknown Primitive Type: " + name, e, DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName); } valid = matchTextualCase(jsonNode, primKind) || matchNumberCase(jsonNode, primKind) || matchBooleanCase(jsonNode, primKind) || matchIEEENumberCase(jsonNode, primKind) || jsonNode.isObject() && name.startsWith("Geo"); } if (!valid) { throw new DeserializerException( "Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName); } }
type = ((EdmTypeDefinition) type).getUnderlyingType();
type = ((EdmTypeDefinition) type).getUnderlyingType();
private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType, final JsonNode jsonNode) throws DeserializerException { boolean valid = true; if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) { checkJsonTypeBasedOnPrimitiveType(propertyName, ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode); } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) { // Enum values must be strings. valid = jsonNode.isTextual(); } else { final String name = edmPrimitiveType.getName(); EdmPrimitiveTypeKind primKind; try { primKind = EdmPrimitiveTypeKind.valueOf(name); } catch (final IllegalArgumentException e) { throw new DeserializerException("Unknown Primitive Type: " + name, e, DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName); } valid = matchTextualCase(jsonNode, primKind) || matchNumberCase(jsonNode, primKind) || matchBooleanCase(jsonNode, primKind) || matchIEEENumberCase(jsonNode, primKind); } if (!valid) { throw new DeserializerException("Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName); } }
col.setType(ColumnType.Scalar); col.setColumnDataType(((EdmTypeDefinition) targetEntityType.getProperty(propertyName).getType()) .getUnderlyingType().getFullQualifiedName().getFullQualifiedNameAsString()); } else {
public Column formNewColumnObject(EdmStructuredType targetEntityType, String propertyName, String dbalias, boolean isKey, String parentComplexName,ReadEntityInfo eInfo) { Column col =null; col = new Column(); col.setpKey(isKey); col.setName(propertyName); col.setDbaliasName(convertToUpperCaseIfRequired(dbalias + ALIASHLP + propertyName)); if (parentComplexName != null) { col.setPathName(parentComplexName + "." + propertyName); } else { col.setPathName(propertyName); } if (targetEntityType.getProperty(propertyName).getType() instanceof EdmTypeDefinition) { col.setType(ColumnType.Scalar); col.setColumnDataType(((EdmTypeDefinition) targetEntityType.getProperty(propertyName).getType()) .getUnderlyingType().getFullQualifiedName().getFullQualifiedNameAsString()); } else { col.setType(ColumnType.Primitive); col.setColumnDataType(targetEntityType.getProperty(propertyName).getType().getFullQualifiedName() .getFullQualifiedNameAsString()); } return col; }