writer.writeAttribute(XML_NAME, term.getName()); writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(term.getType(), false)); if (term.getBaseTerm() != null) { writer.writeAttribute(XML_BASE_TERM, getAliasedFullQualifiedName(term.getBaseTerm().getFullQualifiedName(), false)); if (term.getAppliesTo() != null && !term.getAppliesTo().isEmpty()) { String appliesToString = ""; boolean first = true; for (TargetType target : term.getAppliesTo()) { if (first) { first = false; if (!term.isNullable()) { writer.writeAttribute(XML_NULLABLE, "" + term.isNullable()); if (term.getDefaultValue() != null) { writer.writeAttribute(XML_DEFAULT_VALUE, term.getDefaultValue()); if (term.getMaxLength() != null) { writer.writeAttribute(XML_MAX_LENGTH, "" + term.getMaxLength()); if (term.getPrecision() != null) { writer.writeAttribute(XML_PRECISION, "" + term.getPrecision()); if (term.getScale() != null) { writer.writeAttribute(XML_SCALE, "" + term.getScale());
public static void addAnnotations( final EdmEnabledODataClient client, final Map<Class<? extends AbstractTerm>, Object> annotations, final ClientAnnotatable annotatable) { for (Map.Entry<Class<? extends AbstractTerm>, Object> entry : annotations.entrySet()) { final Namespace nsAnn = entry.getKey().getAnnotation(Namespace.class); final Term termAnn = entry.getKey().getAnnotation(Term.class); final FullQualifiedName termName = new FullQualifiedName(nsAnn.value(), termAnn.name()); final EdmTerm term = client.getCachedEdm().getTerm(termName); if (term == null) { LOG.error("Could not find term for class {}", entry.getKey().getName()); } else { annotatable.getAnnotations().add(getODataAnnotation( client, term.getFullQualifiedName().toString(), term.getType(), entry.getValue())); } } }
@Override public EdmAnnotation getAnnotation(final EdmTerm term, String qualifier) { EdmAnnotation result = null; for (EdmAnnotation annotation : getAnnotations()) { if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName()) && qualifierEqual(qualifier, annotation.getQualifier())) { result = annotation; break; } } return result; }
private void odataAnnotations(final Annotatable annotatable, final ClientAnnotatable odataAnnotatable) { for (Annotation annotation : annotatable.getAnnotations()) { FullQualifiedName fqn = null; if (client instanceof EdmEnabledODataClient) { final EdmTerm term = ((EdmEnabledODataClient) client).getCachedEdm(). getTerm(new FullQualifiedName(annotation.getTerm())); if (term != null) { fqn = term.getType().getFullQualifiedName(); } } if (fqn == null && annotation.getType() != null) { final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build(); if (typeInfo.isPrimitiveType()) { fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName(); } } final ClientAnnotation odataAnnotation = new ClientAnnotationImpl(annotation.getTerm(), getODataValue(fqn, annotation, null, null)); odataAnnotatable.getAnnotations().add(odataAnnotation); } }
@Override public EdmAnnotation getAnnotation(final EdmTerm term, String qualifier) { EdmAnnotation result = null; for (EdmAnnotation annotation : getAnnotations()) { if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName()) && qualifierEqual(qualifier, annotation.getQualifier())) { result = annotation; break; } } return result; }
public static void addAnnotations( final EdmEnabledODataClient client, final Map<Class<? extends AbstractTerm>, Object> annotations, final ClientAnnotatable annotatable) { for (Map.Entry<Class<? extends AbstractTerm>, Object> entry : annotations.entrySet()) { final Namespace nsAnn = entry.getKey().getAnnotation(Namespace.class); final Term termAnn = entry.getKey().getAnnotation(Term.class); final FullQualifiedName termName = new FullQualifiedName(nsAnn.value(), termAnn.name()); final EdmTerm term = client.getCachedEdm().getTerm(termName); if (term == null) { LOG.error("Could not find term for class {}", entry.getKey().getName()); } else { annotatable.getAnnotations().add(getODataAnnotation( client, term.getFullQualifiedName().toString(), term.getType(), entry.getValue())); } } }
private void odataAnnotations(final Annotatable annotatable, final ClientAnnotatable odataAnnotatable) { for (Annotation annotation : annotatable.getAnnotations()) { FullQualifiedName fqn = null; if (client instanceof EdmEnabledODataClient) { final EdmTerm term = ((EdmEnabledODataClient) client).getCachedEdm(). getTerm(new FullQualifiedName(annotation.getTerm())); if (term != null) { fqn = term.getType().getFullQualifiedName(); } } if (fqn == null && annotation.getType() != null) { final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build(); if (typeInfo.isPrimitiveType()) { fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName(); } } final ClientAnnotation odataAnnotation = new ClientAnnotationImpl(annotation.getTerm(), getODataValue(fqn, annotation, null, null)); odataAnnotatable.getAnnotations().add(odataAnnotation); } }
writer.writeAttribute(XML_NAME, term.getName()); writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(term.getType(), false)); if (term.getBaseTerm() != null) { writer.writeAttribute(XML_BASE_TERM, getAliasedFullQualifiedName(term.getBaseTerm().getFullQualifiedName(), false)); if (term.getAppliesTo() != null && !term.getAppliesTo().isEmpty()) { String appliesToString = ""; boolean first = true; for (TargetType target : term.getAppliesTo()) { if (first) { first = false; if (!term.isNullable()) { writer.writeAttribute(XML_NULLABLE, "" + term.isNullable()); if (term.getDefaultValue() != null) { writer.writeAttribute(XML_DEFAULT_VALUE, term.getDefaultValue()); if (term.getMaxLength() != null) { writer.writeAttribute(XML_MAX_LENGTH, "" + term.getMaxLength()); if (term.getPrecision() != null) { writer.writeAttribute(XML_PRECISION, "" + term.getPrecision()); if (term.getScale() != null) { writer.writeAttribute(XML_SCALE, "" + term.getScale());
private void appendAnnotations(final XMLStreamWriter writer, final EdmAnnotatable annotatable) throws XMLStreamException { List<EdmAnnotation> annotations = annotatable.getAnnotations(); if (annotations != null && !annotations.isEmpty()) { for (EdmAnnotation annotation : annotations) { writer.writeStartElement(XML_ANNOTATION); if (annotation.getTerm() != null) { writer.writeAttribute(XML_TERM_ATT, getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName(), false)); } if (annotation.getQualifier() != null) { writer.writeAttribute(XML_QUALIFIER_ATT, annotation.getQualifier()); } appendExpression(writer, annotation.getExpression()); appendAnnotations(writer, annotation); writer.writeEndElement(); } } }
private void appendTerms(final JsonGenerator json, final List<EdmTerm> terms) throws SerializerException, IOException { for (EdmTerm term : terms) { json.writeObjectFieldStart(term.getName()); json.writeStringField(KIND, Kind.Term.name()); json.writeStringField(TYPE, getAliasedFullQualifiedName(term.getType())); if (term.getBaseTerm() != null) { json.writeStringField(BASE_TERM, getAliasedFullQualifiedName(term.getBaseTerm().getFullQualifiedName())); if (term.getAppliesTo() != null && !term.getAppliesTo().isEmpty()) { String appliesToString = ""; boolean first = true; for (TargetType target : term.getAppliesTo()) { if (first) { first = false; if (!term.isNullable()) { json.writeBooleanField(NULLABLE, term.isNullable()); if (term.getDefaultValue() != null) { json.writeStringField(DEFAULT_VALUE, term.getDefaultValue()); if (term.getMaxLength() != null) { json.writeNumberField(MAX_LENGTH, term.getMaxLength()); if (term.getPrecision() != null) { json.writeNumberField(PRECISION, term.getPrecision());
private void appendAnnotations(final XMLStreamWriter writer, final EdmAnnotatable annotatable) throws XMLStreamException { List<EdmAnnotation> annotations = annotatable.getAnnotations(); if (annotations != null && !annotations.isEmpty()) { for (EdmAnnotation annotation : annotations) { writer.writeStartElement(XML_ANNOTATION); if (annotation.getTerm() != null) { writer.writeAttribute(XML_TERM_ATT, getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName(), false)); } if (annotation.getQualifier() != null) { writer.writeAttribute(XML_QUALIFIER_ATT, annotation.getQualifier()); } appendExpression(writer, annotation.getExpression()); appendAnnotations(writer, annotation); writer.writeEndElement(); } } }
private void appendTerms(final JsonGenerator json, final List<EdmTerm> terms) throws SerializerException, IOException { for (EdmTerm term : terms) { json.writeObjectFieldStart(term.getName()); json.writeStringField(KIND, Kind.Term.name()); json.writeStringField(TYPE, getAliasedFullQualifiedName(term.getType())); if (term.getBaseTerm() != null) { json.writeStringField(BASE_TERM, getAliasedFullQualifiedName(term.getBaseTerm().getFullQualifiedName())); if (term.getAppliesTo() != null && !term.getAppliesTo().isEmpty()) { String appliesToString = ""; boolean first = true; for (TargetType target : term.getAppliesTo()) { if (first) { first = false; if (!term.isNullable()) { json.writeBooleanField(NULLABLE, term.isNullable()); if (term.getDefaultValue() != null) { json.writeStringField(DEFAULT_VALUE, term.getDefaultValue()); if (term.getMaxLength() != null) { json.writeNumberField(MAX_LENGTH, term.getMaxLength()); if (term.getPrecision() != null) { json.writeNumberField(PRECISION, term.getPrecision());
private void appendAnnotations(JsonGenerator json, final EdmAnnotatable annotatable, String memberName) throws SerializerException, IOException { List<EdmAnnotation> annotations = annotatable.getAnnotations(); if (annotations != null && !annotations.isEmpty()) { for (EdmAnnotation annotation : annotations) { String termName = memberName != null ? memberName : ""; if (annotation.getTerm() != null) { termName += "@" + getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName()); } if (annotation.getQualifier() != null) { termName += "#" + annotation.getQualifier(); } if (annotation.getExpression() == null && termName.length() > 0) { json.writeBooleanField(termName, true); } else { appendExpression(json, annotation.getExpression(), termName); } appendAnnotations(json, annotation, termName); } } }
private void appendAnnotations(JsonGenerator json, final EdmAnnotatable annotatable, String memberName) throws SerializerException, IOException { List<EdmAnnotation> annotations = annotatable.getAnnotations(); if (annotations != null && !annotations.isEmpty()) { for (EdmAnnotation annotation : annotations) { String termName = memberName != null ? memberName : ""; if (annotation.getTerm() != null) { termName += "@" + getAliasedFullQualifiedName(annotation.getTerm().getFullQualifiedName()); } if (annotation.getQualifier() != null) { termName += "#" + annotation.getQualifier(); } if (annotation.getExpression() == null && termName.length() > 0) { json.writeBooleanField(termName, true); } else { appendExpression(json, annotation.getExpression(), termName); } appendAnnotations(json, annotation, termName); } } }
/** * Replacement character for the XML10 characters that are not supported. * @return */ protected String xml10IncompatibleCharReplacement() { for (EdmSchema schema : getServiceMetaData().getEdm().getSchemas()) { if (schema.getEntityContainer() != null) { for (EdmAnnotation annotation:schema.getAnnotations()) { if (annotation.getTerm() != null && annotation.getTerm().getFullQualifiedName().equals(XML10_CHAR_REPLACE_FQN)) { EdmConstantExpression expr = annotation.getExpression().asConstant(); return expr.getValueAsString(); } } } } return null; }
/** * Replacement character for the XML10 characters that are not supported. * @return */ protected String xml10IncompatibleCharReplacement() { for (EdmSchema schema : getServiceMetaData().getEdm().getSchemas()) { if (schema.getEntityContainer() != null) { for (EdmAnnotation annotation:schema.getAnnotations()) { if (annotation.getTerm() != null && annotation.getTerm().getFullQualifiedName().equals(XML10_CHAR_REPLACE_FQN)) { EdmConstantExpression expr = annotation.getExpression().asConstant(); return expr.getValueAsString(); } } } } return null; }