Java Code Examples for org.apache.olingo.odata2.api.edm.provider.SimpleProperty#setType()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.SimpleProperty#setType() . 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: JPAEdmProperty.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private SimpleProperty buildSimpleProperty(final Attribute<?, ?> jpaAttribute, final SimpleProperty simpleProperty,
    final JoinColumn joinColumn)
    throws ODataJPAModelException, ODataJPARuntimeException {

  boolean isForeignKey = joinColumn != null;
  JPAEdmNameBuilder.build(JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming, isForeignKey);
  EdmSimpleTypeKind simpleTypeKind = JPATypeConverter
      .convertToEdmSimpleType(jpaAttribute
          .getJavaType(), jpaAttribute);
  simpleProperty.setType(simpleTypeKind);
  Facets facets = JPAEdmFacets.createAndSet(jpaAttribute, simpleProperty);
  if(isForeignKey) {
    facets.setNullable(joinColumn.nullable());
  }

  return simpleProperty;

}
 
Example 2
Source File: RestrictionEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   List<Property> properties = new ArrayList<> ();

   SimpleProperty uuid = new SimpleProperty ();
   uuid.setName (UUID);
   uuid.setType (EdmSimpleTypeKind.String);
   uuid.setFacets (new Facets ().setNullable (false));
   uuid.setCustomizableFeedMappings (new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE));
   properties.add (uuid);

   SimpleProperty restriction_type = new SimpleProperty ();
   restriction_type.setName (RESTRICTION_TYPE);
   restriction_type.setType (EdmSimpleTypeKind.String);
   restriction_type.setFacets (new Facets ().setNullable (false));
   properties.add (restriction_type);

   SimpleProperty reason = new SimpleProperty ();
   reason.setName (REASON);
   reason.setType (EdmSimpleTypeKind.String);
   reason.setFacets (new Facets ().setNullable (false));
   properties.add (reason);

   Key key = new Key ();
   List<PropertyRef> propertyRefs = Collections.singletonList (
         new PropertyRef ().setName (UUID));
   key.setKeys (propertyRefs);

   EntityType entityType = new EntityType ();
   entityType.setName (ENTITY_NAME);
   entityType.setProperties (properties);
   entityType.setKey (key);

   return entityType;
}
 
Example 3
Source File: SystemRoleEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   Key key = new Key ();
   List<PropertyRef> property_refs =
         Collections.singletonList (new PropertyRef ().setName (NAME));
   key.setKeys (property_refs);

   SimpleProperty name = new SimpleProperty ();
   name.setName (NAME);
   name.setType (EdmSimpleTypeKind.String);
   name.setFacets (new Facets ().setNullable (false));
   name.setCustomizableFeedMappings (new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE));

   SimpleProperty description = new SimpleProperty ();
   description.setName (DESCRIPTION);
   description.setType (EdmSimpleTypeKind.String);
   description.setFacets (new Facets ().setNullable (false));

   List<Property> properties = new ArrayList<> ();
   properties.add (name);
   properties.add (description);

   EntityType entityType = new EntityType ();
   entityType.setName (ENTITY_NAME);
   entityType.setProperties (properties);
   entityType.setKey (key);

   return entityType;
}
 
Example 4
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Property createSimpleProperty(final EdmProperty ep, final Field field) {
  SimpleProperty sp = new SimpleProperty();
  String entityName = ANNOTATION_HELPER.getPropertyName(field);
  sp.setName(entityName);
  //
  EdmType type = ep.type();
  if (type == EdmType.NULL) {
    type = getEdmType(field.getType());
  }
  sp.setType(ANNOTATION_HELPER.mapTypeKind(type));
  sp.setFacets(createFacets(ep.facets(), field.getAnnotation(EdmConcurrencyControl.class)));
  return sp;
}
 
Example 5
Source File: JPAEdmComplexType.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public void expandEdmComplexType(final ComplexType complexType, List<Property> expandedList,
    final String embeddablePropertyName) {

  if (expandedList == null) {
    expandedList = new ArrayList<Property>();
  }
  for (Property property : complexType.getProperties()) {
    try {
      SimpleProperty newSimpleProperty = new SimpleProperty();
      SimpleProperty oldSimpleProperty = (SimpleProperty) property;
      newSimpleProperty.setAnnotationAttributes(oldSimpleProperty.getAnnotationAttributes());
      newSimpleProperty.setAnnotationElements(oldSimpleProperty.getAnnotationElements());
      newSimpleProperty.setCustomizableFeedMappings(oldSimpleProperty.getCustomizableFeedMappings());
      newSimpleProperty.setDocumentation(oldSimpleProperty.getDocumentation());
      newSimpleProperty.setFacets(oldSimpleProperty.getFacets());
      newSimpleProperty.setMimeType(oldSimpleProperty.getMimeType());
      newSimpleProperty.setName(oldSimpleProperty.getName());
      newSimpleProperty.setType(oldSimpleProperty.getType());
      JPAEdmMappingImpl newMapping = new JPAEdmMappingImpl();
      Mapping mapping = oldSimpleProperty.getMapping();
      JPAEdmMapping oldMapping = (JPAEdmMapping) mapping;
      newMapping.setJPAColumnName(oldMapping.getJPAColumnName());
      newMapping.setInternalName(embeddablePropertyName + "." + mapping.getInternalName());
      newMapping.setObject(mapping.getObject());
      newMapping.setJPAType(oldMapping.getJPAType());
      newSimpleProperty.setMapping(newMapping);
      expandedList.add(newSimpleProperty);
    } catch (ClassCastException e) {
      ComplexProperty complexProperty = (ComplexProperty) property;
      String name = embeddablePropertyName + "." + complexProperty.getMapping().getInternalName();
      expandEdmComplexType(searchComplexTypeByName(complexProperty.getName()), expandedList, name);
    }
  }

}
 
Example 6
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Property readSimpleProperty(final XMLStreamReader reader, final FullQualifiedName fqName)
    throws XMLStreamException {
  SimpleProperty property = new SimpleProperty();
  property.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
  property.setType(EdmSimpleTypeKind.valueOf(fqName.getName()));
  return property;
}
 
Example 7
Source File: ComplexTypesDescriber.java    From cloud-sfsf-benefits-ext with Apache License 2.0 4 votes vote down vote up
private SimpleProperty createProperty(String propertyName, EdmSimpleTypeKind propertyType) {
	SimpleProperty property = new SimpleProperty();
	property.setName(propertyName);
	property.setType(propertyType);
	return property;
}