Java Code Examples for org.apache.olingo.odata2.api.edm.provider.ComplexProperty#setName()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.ComplexProperty#setName() . 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: JPAEdmNameBuilder.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public static void build(final JPAEdmComplexPropertyView complexView,
    final String parentComplexTypeName, final boolean skipDefaultNaming) {
  ComplexProperty complexProperty = complexView.getEdmComplexProperty();

  JPAEdmMappingModelAccess mappingModelAccess = complexView.getJPAEdmMappingModelAccess();
  JPAEdmPropertyView propertyView = ((JPAEdmPropertyView) complexView);
  String jpaAttributeName = propertyView.getJPAAttribute().getName();
  String propertyName = null;
  if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
    propertyName = mappingModelAccess.mapJPAEmbeddableTypeAttribute(parentComplexTypeName, jpaAttributeName);
  }
  if (skipDefaultNaming == false && propertyName == null) {
    propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
  } else if (propertyName == null) {
    propertyName = jpaAttributeName;
  }

  JPAEdmMapping mapping = new JPAEdmMappingImpl();
  ((Mapping) mapping).setInternalName(jpaAttributeName);
  mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
  complexProperty.setMapping((Mapping) mapping);
  complexProperty.setName(propertyName);

}
 
Example 2
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Property createComplexProperty(EdmProperty ep, final Field field) {
  ComplexProperty cp = new ComplexProperty();
  // settings from property
  String entityName = ANNOTATION_HELPER.getPropertyName(field);
  cp.setName(entityName);

  // settings from related complex entity
  FullQualifiedName fqn = ANNOTATION_HELPER.extractComplexTypeFqn(field.getType());
  cp.setType(fqn);

  cp.setFacets(createFacets(ep.facets(), field.getAnnotation(EdmConcurrencyControl.class)));
  
  return cp;
}
 
Example 3
Source File: JPAEdmNameBuilder.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public static void build(final JPAEdmComplexPropertyView complexView,
    final JPAEdmPropertyView propertyView, final boolean skipDefaultNaming) {

  ComplexProperty complexProperty = complexView.getEdmComplexProperty();

  String jpaAttributeName = propertyView.getJPAAttribute().getName();
  String jpaEntityTypeName = propertyView.getJPAEdmEntityTypeView().getJPAEntityType().getName();

  JPAEdmMappingModelAccess mappingModelAccess = complexView.getJPAEdmMappingModelAccess();
  String propertyName = null;

  if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
    propertyName = mappingModelAccess.mapJPAAttribute(jpaEntityTypeName, jpaAttributeName);
  }

  if (skipDefaultNaming == false && propertyName == null) {
    propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
  } else if (propertyName == null) {
    propertyName = jpaAttributeName;
  }

  // change for navigation property issue
  JPAEdmMapping mapping = new JPAEdmMappingImpl();
  ((Mapping) mapping).setInternalName(jpaAttributeName);
  mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
  complexProperty.setMapping((Mapping) mapping);

  complexProperty.setName(propertyName);

}
 
Example 4
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Property readComplexProperty(final XMLStreamReader reader, final FullQualifiedName fqName)
    throws XMLStreamException {
  ComplexProperty property = new ComplexProperty();
  property.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
  property.setType(fqName);
  return property;
}