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

The following examples show how to use org.apache.olingo.commons.api.edm.FullQualifiedName#getNamespace() . 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 6 votes vote down vote up
@Override
protected EdmTerm createTerm(final FullQualifiedName termName) {
  try {
    CsdlTerm providerTerm = provider.getTerm(termName);
    if (providerTerm != null) {
      return new EdmTermImpl(this, termName.getNamespace(), providerTerm);
    } else {
        for (CsdlSchema schema : termSchemaDefinition) {
            if (schema.getNamespace().equalsIgnoreCase(termName.getNamespace()) ||
                (null != schema.getAlias() && 
                schema.getAlias().equalsIgnoreCase(termName.getNamespace()))) {
              List<CsdlTerm> terms = schema.getTerms();
              for (CsdlTerm term : terms) {
                if (term.getName().equals(termName.getName())) {
                  return new EdmTermImpl(this, termName.getNamespace(), term);
                }
              }
            }
          }
      }
    return null;
  } catch (ODataException e) {
    throw new EdmException(e);
  }
}
 
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 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 3
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 4
Source File: EdmProviderImpl.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
/**
 * Removes the annotation added on complex type property via Entity Set
 * @param structuralType
 * @param typeName
 * @param csdlEntityContainer
 * @param properties
 * @param entitySets
 */
private void removeAnnotationsAddedToCTTypePropFromES(CsdlStructuralType structuralType, FullQualifiedName typeName,
    CsdlEntityContainer csdlEntityContainer, List<CsdlProperty> properties, List<CsdlEntitySet> entitySets) {
  String containerName;
  String schemaName;
  String complexPropName;
  for (CsdlEntitySet entitySet : entitySets) {
    try {
      CsdlEntityType entType = provider.getEntityType(entitySet.getTypeFQN());
      List<CsdlProperty> entTypeProperties = null != entType ? 
          entType.getProperties() : new ArrayList<>();
      for (CsdlProperty entTypeProperty : entTypeProperties) {
        if (null != entTypeProperty.getType() && 
            entTypeProperty.getType().endsWith(DOT + structuralType.getName())) {
          complexPropName = entTypeProperty.getName();
          containerName = csdlEntityContainer.getName();
          schemaName = typeName.getNamespace();
          for (CsdlProperty property : properties) { 
            List<CsdlAnnotation> annotPropDerivedFromES = getAnnotationsMap().get(schemaName + DOT + 
                containerName + SLASH +  entitySet.getName() + SLASH + complexPropName + SLASH + property.getName());
            removeAnnotationsOnPropDerivedFromEntitySet(structuralType, property, annotPropDerivedFromES);
            String aliasName = getAliasInfo(schemaName);
            List<CsdlAnnotation> annotPropDerivedFromESOnAlias = getAnnotationsMap().get(aliasName + DOT + 
                containerName + SLASH +  entitySet.getName() + SLASH + complexPropName + 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(typeName.getName() + SLASH + property.getName());
            addAnnotationsOnPropertiesOfStructuralType(structuralType, property, propAnnotationsOnAlias);
          }
        }
      }
    } catch (ODataException e) {
      throw new EdmException(e);
    }
  }
}