Java Code Examples for org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer#getEntitySets()

The following examples show how to use org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer#getEntitySets() . 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: EdmProviderImpl.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/** Check if annotations are added on navigation properties of a structural type
 * @param structuralType
 * @param typeName
 * @param csdlEntityContainer 
 * @param isNavPropAnnotationsCleared
 * @param annotationGrp
 */
private void updateAnnotationsOnStructuralNavProperties(CsdlStructuralType structuralType, 
    FullQualifiedName typeName, CsdlEntityContainer csdlEntityContainer) {
  List<CsdlNavigationProperty> navProperties = structuralType.getNavigationProperties();
  String containerName = null;
  String schemaName = null;
  String entitySetName = null;
  List<CsdlEntitySet> entitySets = csdlEntityContainer != null ? 
      csdlEntityContainer.getEntitySets() : new ArrayList<CsdlEntitySet>();
  if (structuralType instanceof CsdlComplexType) {
    removeAnnotationsAddedToCTNavPropFromES(structuralType, typeName, csdlEntityContainer, navProperties, entitySets);
  } else {
    for (CsdlEntitySet entitySet : entitySets) {
      entitySetName = entitySet.getName();
      String entityTypeName = entitySet.getTypeFQN().getFullQualifiedNameAsString();
      if (null != entityTypeName && entityTypeName.equalsIgnoreCase(typeName.getFullQualifiedNameAsString())) {
        containerName = csdlEntityContainer.getName();
        schemaName = typeName.getNamespace();
        break;
      }
    }
    for (CsdlNavigationProperty navProperty : navProperties) {
      List<CsdlAnnotation> annotPropDerivedFromES = getAnnotationsMap().get(schemaName + DOT + 
          containerName + SLASH +  entitySetName + SLASH + navProperty.getName());
      removeAnnotationsOnNavPropDerivedFromEntitySet(structuralType, navProperty, annotPropDerivedFromES);
      String aliasName = getAliasInfo(schemaName);
      List<CsdlAnnotation> annotPropDerivedFromESOnAlias = getAnnotationsMap().get(aliasName + DOT + 
          containerName + SLASH +  entitySetName + SLASH + navProperty.getName());
      removeAnnotationsOnNavPropDerivedFromEntitySet(structuralType, navProperty, annotPropDerivedFromESOnAlias);
      
      List<CsdlAnnotation> navPropAnnotations = getAnnotationsMap().get(
          typeName + SLASH + navProperty.getName());
      addAnnotationsOnNavProperties(structuralType, navProperty, navPropAnnotations);
      aliasName = getAliasInfo(typeName.getNamespace());
      List<CsdlAnnotation> navPropAnnotationsOnAlias = getAnnotationsMap().get(
          aliasName + DOT + typeName.getName() + SLASH + navProperty.getName());
      addAnnotationsOnNavProperties(structuralType, navProperty, navPropAnnotationsOnAlias);
    }
  }
}
 
Example 2
Source File: EdmProviderImpl.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/** Check if annotations are added on properties of a structural type
 * @param structuralType
 * @param typeName
 * @param csdlEntityContainer
 */
private void updateAnnotationsOnStructuralProperties(CsdlStructuralType structuralType, FullQualifiedName typeName,
    CsdlEntityContainer csdlEntityContainer) {
  List<CsdlProperty> properties = structuralType.getProperties();
  String containerName = null;
  String schemaName = null;
  String entitySetName = null;
  List<CsdlEntitySet> entitySets = null != csdlEntityContainer ? 
      csdlEntityContainer.getEntitySets() : new ArrayList<>();
  if (structuralType instanceof CsdlComplexType) {
    removeAnnotationsAddedToCTTypePropFromES(structuralType, typeName, csdlEntityContainer, properties, entitySets);
  } else {
    for (CsdlEntitySet entitySet : entitySets) {
      entitySetName = entitySet.getName();
      String entityTypeName = entitySet.getTypeFQN().getFullQualifiedNameAsString();
      if (null != entityTypeName && entityTypeName.equalsIgnoreCase(typeName.getFullQualifiedNameAsString())) {
        containerName = csdlEntityContainer.getName();
        schemaName = typeName.getNamespace();
        break;
      }
    }
    for (CsdlProperty property : properties) {
      List<CsdlAnnotation> annotPropDerivedFromES = getAnnotationsMap().get(schemaName + DOT + 
          containerName + SLASH +  entitySetName + SLASH + property.getName());
      removeAnnotationsOnPropDerivedFromEntitySet(structuralType, property, annotPropDerivedFromES);
      String aliasName = getAliasInfo(schemaName);
      List<CsdlAnnotation> annotPropDerivedFromESOnAlias = getAnnotationsMap().get(aliasName + DOT + 
          containerName + SLASH +  entitySetName + SLASH + property.getName());
      removeAnnotationsOnPropDerivedFromEntitySet(structuralType, property, annotPropDerivedFromESOnAlias);
      List<CsdlAnnotation> propAnnotations = getAnnotationsMap().
          get(typeName.getFullQualifiedNameAsString() + SLASH + property.getName());
      addAnnotationsOnPropertiesOfStructuralType(structuralType, property, propAnnotations);
      aliasName = getAliasInfo(typeName.getNamespace());
      List<CsdlAnnotation> propAnnotationsOnAlias = getAnnotationsMap().
          get(aliasName + DOT + typeName.getName() + SLASH + property.getName());
      addAnnotationsOnPropertiesOfStructuralType(structuralType, property, propAnnotationsOnAlias);
    }
  }
}
 
Example 3
Source File: SchemaBasedEdmProvider.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public CsdlEntitySet getEntitySet(FullQualifiedName fqn, String entitySetName) throws ODataException {
  CsdlSchema schema = getSchema(fqn.getNamespace());
  if (schema != null) {
    CsdlEntityContainer ec = schema.getEntityContainer();
    if (ec != null && ec.getEntitySets() != null) {
      for (CsdlEntitySet es : ec.getEntitySets()) {
        if (es.getName().equals(entitySetName)) {
          return es;
        }
      }
    }
  }
  return null;
}