Java Code Examples for org.apache.olingo.commons.api.edm.FullQualifiedName#getName()

The following examples show how to use org.apache.olingo.commons.api.edm.FullQualifiedName#getName() . 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: CsdlTypeValidator.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
/**
 * fetch the actual navigation property from the remaning path
 * @param remainingPath
 * @param strNavProperty
 * @param sourceTypeHavingNavProp
 * @return CsdlNavigationProperty
 */
private CsdlNavigationProperty fetchNavigationProperty(String remainingPath,
    String strNavProperty, CsdlStructuralType sourceTypeHavingNavProp) {
  String[] paths = remainingPath.split("/");
  for (String path : paths) {
    FullQualifiedName fqName = null;
    if (sourceTypeHavingNavProp instanceof CsdlComplexType) {
      fqName = ((CsdlComplexType)sourceTypeHavingNavProp).getProperty(path).getTypeAsFQNObject();
    } else if (sourceTypeHavingNavProp instanceof CsdlEntityType) {
      fqName = ((CsdlEntityType)sourceTypeHavingNavProp).getProperty(path).getTypeAsFQNObject();
    }
    if (fqName != null) {
      String namespace = aliasNamespaceMap.get(fqName.getNamespace());
      fqName = namespace != null ? new FullQualifiedName(namespace, fqName.getName()) : fqName;
    }
    
    sourceTypeHavingNavProp = csdlEntityTypesMap.get(fqName) != null ? 
        csdlEntityTypesMap.get(fqName) : 
          csdlComplexTypesMap.get(fqName);
  }
  return sourceTypeHavingNavProp.getNavigationProperty(strNavProperty);
}
 
Example 2
Source File: EdmTypeValidator.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch the correct navigation property from the remaining path
 * @param remainingPath
 * @param strNavProperty
 * @param sourceTypeHavingNavProp
 * @return EdmNavigationProperty
 */
private EdmNavigationProperty fetchNavigationProperty(String remainingPath,
    String strNavProperty, EdmStructuredType sourceTypeHavingNavProp) {
  String[] paths = remainingPath.split("/");
  for (String path : paths) {
    FullQualifiedName fqName = null;
    if (sourceTypeHavingNavProp instanceof EdmComplexType) {
      fqName = ((EdmComplexType)sourceTypeHavingNavProp).getProperty(path).getType().getFullQualifiedName();
    } else if (sourceTypeHavingNavProp instanceof EdmEntityType) {
      fqName = ((EdmEntityType)sourceTypeHavingNavProp).getProperty(path).getType().getFullQualifiedName();
    }
    if (fqName != null) {
      String namespace = aliasNamespaceMap.get(fqName.getNamespace());
      fqName = namespace != null ? new FullQualifiedName(namespace, fqName.getName()) : fqName;
    }
    
    sourceTypeHavingNavProp = edmEntityTypesMap.containsKey(fqName) ? 
        edmEntityTypesMap.get(fqName) : 
          edmComplexTypesMap.get(fqName);
  }
  return sourceTypeHavingNavProp.getNavigationProperty(strNavProperty);
}
 
Example 3
Source File: EdmEntityContainerImpl.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
public EdmEntityContainerImpl(final Edm edm, final CsdlEdmProvider provider, final FullQualifiedName containerFQN,
    final CsdlEntityContainer entityContainer) {
  super(edm, containerFQN.getName(), entityContainer);
  this.provider = provider;
  container = entityContainer;
  entityContainerName = containerFQN;
  parentContainerName = entityContainer == null ? null : 
    entityContainer.getExtendsContainerFQN();
}
 
Example 4
Source File: MetadataDocumentJsonSerializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private void appendFunctionImports(final JsonGenerator json, final List<EdmFunctionImport> functionImports,
    final String containerNamespace) throws SerializerException, IOException {
  for (EdmFunctionImport functionImport : functionImports) {
    json.writeObjectFieldStart(functionImport.getName());

    json.writeStringField(KIND, Kind.FunctionImport.name());
    String functionFQNString;
    FullQualifiedName functionFqn = functionImport.getFunctionFqn();
    if (namespaceToAlias.get(functionFqn.getNamespace()) != null) {
      functionFQNString = namespaceToAlias.get(functionFqn.getNamespace()) + "." + functionFqn.getName();
    } else {
      functionFQNString = functionFqn.getFullQualifiedNameAsString();
    }
    json.writeStringField(DOLLAR + Kind.Function.name(), functionFQNString);

    EdmEntitySet returnedEntitySet = functionImport.getReturnedEntitySet();
    if (returnedEntitySet != null) {
      json.writeStringField(DOLLAR + Kind.EntitySet.name(), 
          containerNamespace + "." + returnedEntitySet.getName());
    }
    // Default is false and we do not write the default
    if (functionImport.isIncludeInServiceDocument()) {
      json.writeBooleanField(INCLUDE_IN_SERV_DOC, functionImport.isIncludeInServiceDocument());
    }
    appendAnnotations(json, functionImport, null);
    json.writeEndObject();
  }
}
 
Example 5
Source File: MetadataDocumentJsonSerializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private String getAliasedFullQualifiedName(final FullQualifiedName fqn) {
  final String name;
  if (namespaceToAlias.get(fqn.getNamespace()) != null) {
    name = namespaceToAlias.get(fqn.getNamespace()) + "." + fqn.getName();
  } else {
    name = fqn.getFullQualifiedNameAsString();
  }

  return name;
}
 
Example 6
Source File: MetadataDocumentXmlSerializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private void appendFunctionImports(final XMLStreamWriter writer, final List<EdmFunctionImport> functionImports,
    final String containerNamespace) throws XMLStreamException {
  for (EdmFunctionImport functionImport : functionImports) {
    writer.writeStartElement(XML_FUNCTION_IMPORT);
    writer.writeAttribute(XML_NAME, functionImport.getName());

    String functionFQNString;
    FullQualifiedName functionFqn = functionImport.getFunctionFqn();
    if (namespaceToAlias.get(functionFqn.getNamespace()) != null) {
      functionFQNString = namespaceToAlias.get(functionFqn.getNamespace()) + "." + functionFqn.getName();
    } else {
      functionFQNString = functionFqn.getFullQualifiedNameAsString();
    }
    writer.writeAttribute(XML_FUNCTION, functionFQNString);

    EdmEntitySet returnedEntitySet = functionImport.getReturnedEntitySet();
    if (returnedEntitySet != null) {
      String returnedEntitySetNamespace = returnedEntitySet.getEntityContainer().getNamespace();
      if ((null != returnedEntitySetNamespace && returnedEntitySetNamespace.equals(containerNamespace)) || (
          namespaceToAlias.get(returnedEntitySetNamespace) != null && 
          namespaceToAlias.get(returnedEntitySetNamespace).equals(containerNamespace))) {
        writer.writeAttribute(XML_ENTITY_SET, returnedEntitySet.getName());
      } else {
        writer.writeAttribute(XML_ENTITY_SET, containerNamespace + "." + returnedEntitySet.getName());
      }
    }
    // Default is false and we do not write the default
    if (functionImport.isIncludeInServiceDocument()) {
      writer.writeAttribute(XML_INCLUDE_IN_SERVICE_DOCUMENT, "" + functionImport.isIncludeInServiceDocument());
    }
    appendAnnotations(writer, functionImport);
    writer.writeEndElement();
  }
}
 
Example 7
Source File: MetadataDocumentXmlSerializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private String getAliasedFullQualifiedName(final FullQualifiedName fqn, final boolean isCollection) {
  final String name;
  if (namespaceToAlias.get(fqn.getNamespace()) != null) {
    name = namespaceToAlias.get(fqn.getNamespace()) + "." + fqn.getName();
  } else {
    name = fqn.getFullQualifiedNameAsString();
  }

  return isCollection ? "Collection(" + name + ")" : name;
}
 
Example 8
Source File: CsdlTypeValidator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * This validates the namespace to alias mapping
 * @param fQName
 * @return FullQualifiedName
 */
private FullQualifiedName validateCsdlEntityTypeWithAlias(FullQualifiedName fQName) {
  String namespace = aliasNamespaceMap.get(fQName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, fQName.getName());
  if (!csdlEntityTypesMap.containsKey(fqName)) {
    throw new RuntimeException("Invalid Entity Type " + fQName);
  }
  return fqName;
}
 
Example 9
Source File: CsdlTypeValidator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * This validates the namespace to alias mapping
 * @param aliasName
 * @return
 */
private FullQualifiedName validateCsdlComplexTypeWithAlias(FullQualifiedName aliasName) {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!csdlComplexTypesMap.containsKey(fqName)) {
    throw new RuntimeException("Invalid Complex BaseType " + aliasName);
  }
  return fqName;
}
 
Example 10
Source File: CsdlTypeValidator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * This validates the namespace to alias mapping
 * @param aliasName
 * @return FullQualifiedName
 */
private FullQualifiedName validateCsdlActionsWithAlias(FullQualifiedName aliasName) {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!csdlActionsMap.containsKey(fqName)) {
    throw new RuntimeException("Invalid Action " + aliasName);
  }
  return fqName;
}
 
Example 11
Source File: CsdlTypeValidator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * This validates the namespace to alias mapping
 * @param aliasName
 * @return FullQualifiedName
 */
private FullQualifiedName validateCsdlFunctionsWithAlias(FullQualifiedName aliasName) {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!csdlFunctionsMap.containsKey(fqName)) {
    throw new RuntimeException("Invalid Function " + aliasName);
  }
  return fqName;
}
 
Example 12
Source File: EdmTypeValidator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * This validates the namespace to alias mapping
 * @param aliasName
 * @return FullQualifiedName
 */
private FullQualifiedName validateEdmFunctionsWithAlias(FullQualifiedName aliasName) {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!edmFunctionsMap.containsKey(fqName)) {
    throw new RuntimeException("Invalid Function " + aliasName);
  }
  return fqName;
}
 
Example 13
Source File: EdmTypeImpl.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
public EdmTypeImpl(final Edm edm, final FullQualifiedName typeName, final EdmTypeKind kind,
    final CsdlAnnotatable annotatable) {
  super(edm, typeName.getName(), annotatable);
  this.typeName = typeName;
  this.kind = kind;
}
 
Example 14
Source File: MetadataDocumentJsonSerializer.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private void appendEntityContainer(final JsonGenerator json, 
    final EdmEntityContainer container) throws SerializerException, IOException {
  if (container != null) {
    json.writeObjectFieldStart(container.getName());
    json.writeStringField(KIND, Kind.EntityContainer.name());
    FullQualifiedName parentContainerName = container.getParentContainerName();
    if (parentContainerName != null) {
      String parentContainerNameString;
      if (namespaceToAlias.get(parentContainerName.getNamespace()) != null) {
        parentContainerNameString =
            namespaceToAlias.get(parentContainerName.getNamespace()) + "." + parentContainerName.getName();
      } else {
        parentContainerNameString = parentContainerName.getFullQualifiedNameAsString();
      }
      json.writeObjectFieldStart(Kind.Extending.name());
      json.writeStringField(KIND, Kind.EntityContainer.name());
      json.writeStringField(EXTENDS, parentContainerNameString);
      json.writeEndObject();
    }

    // EntitySets
    appendEntitySets(json, container.getEntitySets());

    String containerNamespace;
    if (namespaceToAlias.get(container.getNamespace()) != null) {
      containerNamespace = namespaceToAlias.get(container.getNamespace());
    } else {
      containerNamespace = container.getNamespace();
    }
    // ActionImports
    appendActionImports(json, container.getActionImports(), containerNamespace);
   
    // FunctionImports
    appendFunctionImports(json, container.getFunctionImports(), containerNamespace);

     
    // Singletons
    appendSingletons(json, container.getSingletons());

    // Annotations
    appendAnnotations(json, container, null);

    json.writeEndObject();
  }
  
}
 
Example 15
Source File: MetadataDocumentXmlSerializer.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private void appendEntityContainer(final XMLStreamWriter writer, final EdmEntityContainer container)
    throws XMLStreamException {
  if (container != null) {
    writer.writeStartElement(XML_ENTITY_CONTAINER);

    writer.writeAttribute(XML_NAME, container.getName());
    FullQualifiedName parentContainerName = container.getParentContainerName();
    if (parentContainerName != null) {
      String parentContainerNameString;
      if (namespaceToAlias.get(parentContainerName.getNamespace()) != null) {
        parentContainerNameString =
            namespaceToAlias.get(parentContainerName.getNamespace()) + "." + parentContainerName.getName();
      } else {
        parentContainerNameString = parentContainerName.getFullQualifiedNameAsString();
      }
      writer.writeAttribute(XML_EXTENDS, parentContainerNameString);
    }

    // EntitySets
    appendEntitySets(writer, container.getEntitySets());

    // ActionImports
    appendActionImports(writer, container.getActionImports());

    // FunctionImports
    String containerNamespace;
    if (namespaceToAlias.get(container.getNamespace()) != null) {
      containerNamespace = namespaceToAlias.get(container.getNamespace());
    } else {
      containerNamespace = container.getNamespace();
    }
    appendFunctionImports(writer, container.getFunctionImports(), containerNamespace);

    // Singletons
    appendSingletons(writer, container.getSingletons());

    // Annotations
    appendAnnotations(writer, container);

    writer.writeEndElement();
  }
}