Java Code Examples for org.apache.olingo.commons.api.edm.EdmType#getFullQualifiedName()

The following examples show how to use org.apache.olingo.commons.api.edm.EdmType#getFullQualifiedName() . 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: ODataBinderImpl.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
private EdmTypeInfo buildTypeInfo(final ContextURL contextURL, final String metadataETag,
    final String propertyName, final String propertyType) {

  FullQualifiedName typeName = null;
  final EdmType type = findType(null, contextURL, metadataETag);
  if (type instanceof EdmStructuredType) {
    final EdmProperty edmProperty = ((EdmStructuredType) type).getStructuralProperty(propertyName);
    if (edmProperty != null) {
      typeName = edmProperty.getType().getFullQualifiedName();
    }
  }
  if (typeName == null && type != null) {
    typeName = type.getFullQualifiedName();
  }

  return buildTypeInfo(typeName, propertyType);
}
 
Example 2
Source File: DataProvider.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private Map<String, Object> findFreeComposedKey(final List<Entity> entities, final EdmEntityType entityType)
    throws DataProviderException {
  // Weak key construction
  final HashMap<String, Object> keys = new HashMap<String, Object>();
  List<String> keyPredicateNames = entityType.getKeyPredicateNames();
  for (final String keyName : keyPredicateNames) {
    EdmType type = entityType.getProperty(keyName).getType();
    FullQualifiedName typeName = type.getFullQualifiedName();
    if (type instanceof EdmTypeDefinition) {
      typeName = ((EdmTypeDefinition) type).getUnderlyingType().getFullQualifiedName();
    }
    Object newValue;

    if (EdmPrimitiveTypeKind.Int16.getFullQualifiedName().equals(typeName)) {
      newValue = (short) KEY_INT_16.incrementAndGet();

      while (!isFree(newValue, keyName, entities)) {
        newValue = (short) KEY_INT_16.incrementAndGet();
      }
    } else if (EdmPrimitiveTypeKind.Int32.getFullQualifiedName().equals(typeName)) {
      newValue = KEY_INT_32.incrementAndGet();

      while (!isFree(newValue, keyName, entities)) {
        newValue = KEY_INT_32.incrementAndGet();
      }
    } else if (EdmPrimitiveTypeKind.Int64.getFullQualifiedName().equals(typeName)) {
      // Integer keys
      newValue = KEY_INT_64.incrementAndGet();

      while (!isFree(newValue, keyName, entities)) {
        newValue = KEY_INT_64.incrementAndGet();
      }
    } else if (EdmPrimitiveTypeKind.String.getFullQualifiedName().equals(typeName)) {
      // String keys
      newValue = String.valueOf(KEY_STRING.incrementAndGet());

      while (!isFree(newValue, keyName, entities)) {
        newValue = String.valueOf(KEY_STRING.incrementAndGet());
      }
    } else if (type instanceof EdmEnumType) {
      /* In case of an enum key we only support composite keys. This way we can 0 as a key */
      if (keyPredicateNames.size() <= 1) {
        throw new DataProviderException("Single Enum as key not supported", HttpStatusCode.NOT_IMPLEMENTED);
      }
      newValue = new Short((short) 1);
    } else {
      throw new DataProviderException("Key type not supported", HttpStatusCode.NOT_IMPLEMENTED);
    }

    keys.put(keyName, newValue);
  }

  return keys;
}
 
Example 3
Source File: MetadataDocumentJsonSerializer.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private String getAliasedFullQualifiedName(final EdmType type) {
  FullQualifiedName fqn = type.getFullQualifiedName();
  return getAliasedFullQualifiedName(fqn);
}
 
Example 4
Source File: MetadataDocumentXmlSerializer.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private String getAliasedFullQualifiedName(final EdmType type, final boolean isCollection) {
  FullQualifiedName fqn = type.getFullQualifiedName();
  return getAliasedFullQualifiedName(fqn, isCollection);
}