Java Code Examples for org.apache.olingo.commons.api.edm.provider.CsdlSchema#getFunctions()

The following examples show how to use org.apache.olingo.commons.api.edm.provider.CsdlSchema#getFunctions() . 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: SchemaBasedEdmProvider.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Override
public List<CsdlFunction> getFunctions(FullQualifiedName fqn) throws ODataException {
  ArrayList<CsdlFunction> foundFuncs = new ArrayList<>();
  CsdlSchema schema = getSchema(fqn.getNamespace());
  if (schema != null) {
    List<CsdlFunction> functions = schema.getFunctions();
    if (functions != null) {
      for (CsdlFunction func : functions) {
        if (func.getName().equals(fqn.getName())) {
          foundFuncs.add(func);
        }
      }
    }
  }
  return foundFuncs;
}
 
Example 2
Source File: ClientCsdlEdmProvider.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public List<CsdlFunction> getFunctions(final FullQualifiedName functionName) throws ODataException {
  CsdlSchema schema = xmlSchemas.get(functionName.getNamespace());
  if (schema != null) {
    return schema.getFunctions(functionName.getName());
  }
  return null;
}
 
Example 3
Source File: ODataMetadataValidationImpl.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Override
public void validateMetadata(XMLMetadata xmlMetadata) {
  Map<FullQualifiedName, CsdlEntityType> csdlEntityTypesMap = new HashMap<>();
  Map<FullQualifiedName, CsdlComplexType> csdlComplexTypesMap = new HashMap<>();
  Map<FullQualifiedName, CsdlAction> csdlActionsMap = new HashMap<>();
  Map<FullQualifiedName, CsdlFunction> csdlFunctionsMap = new HashMap<>();
  Map<FullQualifiedName, CsdlEntityContainer> csdlContainersMap = 
      new HashMap<>();
  Map<String, String> aliasNamespaceMap = new HashMap<>();
  List<CsdlSchema> csdlSchemas = xmlMetadata.getSchemas();
  for (CsdlSchema csdlSchema : csdlSchemas) {
    List<CsdlEntityType> csdlEntityTypes = csdlSchema.getEntityTypes();
    for (CsdlEntityType csdlEntityType : csdlEntityTypes) {
      csdlEntityTypesMap.put(new FullQualifiedName(
          csdlSchema.getNamespace(), csdlEntityType.getName()), csdlEntityType);
    }
    List<CsdlComplexType> csdlComplexTypes = csdlSchema.getComplexTypes();
    for (CsdlComplexType csdlComplexType : csdlComplexTypes) {
      csdlComplexTypesMap.put(new FullQualifiedName(
          csdlSchema.getNamespace(), csdlComplexType.getName()), csdlComplexType);
    }
    List<CsdlAction> csdlActions = csdlSchema.getActions();
    for (CsdlAction csdlAction : csdlActions) {
      csdlActionsMap.put(new FullQualifiedName(
          csdlSchema.getNamespace(), csdlAction.getName()), csdlAction);
    }
    List<CsdlFunction> csdlFunctions = csdlSchema.getFunctions();
    for (CsdlFunction csdlFunction : csdlFunctions) {
      csdlFunctionsMap.put(
          new FullQualifiedName(csdlSchema.getNamespace(), csdlFunction.getName()), csdlFunction);
    }
    aliasNamespaceMap.put(csdlSchema.getAlias(), csdlSchema.getNamespace());
    if (csdlSchema.getEntityContainer() != null) {
      csdlContainersMap.put(new FullQualifiedName(
          csdlSchema.getNamespace(), csdlSchema.getEntityContainer().getName()), csdlSchema.getEntityContainer());
    }
  }
  CsdlTypeValidator csdlTypeValidator = new CsdlTypeValidator(aliasNamespaceMap, csdlContainersMap, 
      csdlEntityTypesMap, csdlComplexTypesMap, csdlActionsMap, csdlFunctionsMap);
  csdlTypeValidator.validateMetadataXML();
}