Java Code Examples for org.apache.olingo.odata2.api.edm.EdmException#COMMON

The following examples show how to use org.apache.olingo.odata2.api.edm.EdmException#COMMON . 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: EdmEntityContainerImplProv.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public EdmEntityContainerImplProv(final EdmImplProv edm, final EntityContainerInfo entityContainerInfo)
    throws EdmException {
  this.edm = edm;
  this.entityContainerInfo = entityContainerInfo;
  edmEntitySets = new HashMap<String, EdmEntitySet>();
  edmAssociationSets = new HashMap<String, EdmAssociationSet>();
  edmFunctionImports = new HashMap<String, EdmFunctionImport>();
  isDefaultContainer = entityContainerInfo.isDefaultEntityContainer();

  if (entityContainerInfo.getExtendz() != null) {
    edmExtendedEntityContainer = edm.getEntityContainer(entityContainerInfo.getExtendz());
    if (edmExtendedEntityContainer == null) {
      throw new EdmException(EdmException.COMMON);
    }
  }
}
 
Example 2
Source File: EdmTypedImplProv.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public EdmType getType() throws EdmException {
  if (edmType == null) {
    final String namespace = typeName.getNamespace();
    if (EdmSimpleType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
      edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.valueOf(typeName.getName()));
    } else {
      edmType = edm.getComplexType(namespace, typeName.getName());
    }
    if (edmType == null) {
      edmType = edm.getEntityType(namespace, typeName.getName());
    }

    if (edmType == null) {
      throw new EdmException(EdmException.COMMON);
    }

  }
  return edmType;
}
 
Example 3
Source File: EdmAssociationSetImplProv.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public EdmAssociationSetEnd getEnd(final String role) throws EdmException {
  AssociationSetEnd end;

  if (associationSet.getEnd1().getRole().equals(role)) {
    end = associationSet.getEnd1();
  } else if (associationSet.getEnd2().getRole().equals(role)) {
    end = associationSet.getEnd2();
  } else {
    return null;
  }

  EdmEntitySet entitySet = edmEntityContainer.getEntitySet(end.getEntitySet());
  if (entitySet == null) {
    throw new EdmException(EdmException.COMMON);
  }

  return new EdmAssociationSetEndImplProv(end, entitySet);
}
 
Example 4
Source File: EdmEntityTypeImplProv.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public List<String> getKeyPropertyNames() throws EdmException {
  if (edmKeyPropertyNames == null) {
    if (edmBaseType != null) {
      return ((EdmEntityType) edmBaseType).getKeyPropertyNames();
    }

    edmKeyPropertyNames = new ArrayList<String>();

    if (entityType.getKey() != null) {
      for (final PropertyRef keyProperty : entityType.getKey().getKeys()) {
        edmKeyPropertyNames.add(keyProperty.getName());
      }
    } else {
      // Entity Type does not define a key
      throw new EdmException(EdmException.COMMON);
    }
  }

  return edmKeyPropertyNames;
}
 
Example 5
Source File: EdmEntityTypeImplProv.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public List<EdmProperty> getKeyProperties() throws EdmException {
  if (edmKeyProperties == null) {
    if (edmBaseType != null) {
      return ((EdmEntityType) edmBaseType).getKeyProperties();
    }

    if (keyProperties == null) {
      keyProperties = new HashMap<String, EdmProperty>();
      edmKeyProperties = new ArrayList<EdmProperty>();

      for (String keyPropertyName : getKeyPropertyNames()) {
        final EdmTyped edmProperty = getProperty(keyPropertyName);
        if (edmProperty != null && edmProperty instanceof EdmProperty) {
          keyProperties.put(keyPropertyName, (EdmProperty) edmProperty);
          edmKeyProperties.add((EdmProperty) edmProperty);
        } else {
          throw new EdmException(EdmException.COMMON);
        }
      }
    }
  }

  return edmKeyProperties;
}
 
Example 6
Source File: EdmAssociationSetImpl.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public EdmAssociationSetEnd getEnd(final String role) throws EdmException {
  EdmAssociationSetEnd end;
  if (end1.getRole().equals(role)) {
    end = this.end1;
  } else if (end2.getRole().equals(role)) {
    end = this.end2;
  } else {
    return null;
  }
  EdmEntitySet entitySet = edmEntityContainer.getEntitySet(((EdmAssociationSetEndImpl)end).getEntitySetName());
  if (entitySet == null) {
    throw new EdmException(EdmException.COMMON);//TODO
  }
  return end;
}
 
Example 7
Source File: EdmParameterImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmType getType() throws EdmException {
  if (edmType == null) {
    edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(parameter.getType());
    if (edmType == null) {
      throw new EdmException(EdmException.COMMON);
    }
  }
  return edmType;
}
 
Example 8
Source File: EdmAssociationEndImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmEntityType getEntityType() throws EdmException {
  final FullQualifiedName type = associationEnd.getType();
  EdmEntityType entityType = edm.getEntityType(type.getNamespace(), type.getName());
  if (entityType == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return entityType;
}
 
Example 9
Source File: EdmEntityContainerImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmAssociationSet getAssociationSet(final EdmEntitySet sourceEntitySet,
    final EdmNavigationProperty navigationProperty) throws EdmException {
  EdmAssociation edmAssociation = navigationProperty.getRelationship();
  String association = edmAssociation.getNamespace() + "." + edmAssociation.getName();
  String entitySetName = sourceEntitySet.getName();
  String entitySetFromRole = navigationProperty.getFromRole();

  String key = entitySetName + ">>" + association + ">>" + entitySetFromRole;

  EdmAssociationSet edmAssociationSet = edmAssociationSets.get(key);
  if (edmAssociationSet != null) {
    return edmAssociationSet;
  }

  AssociationSet associationSet;
  FullQualifiedName associationFQName =
      new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName());
  try {
    associationSet =
        edm.edmProvider.getAssociationSet(entityContainerInfo.getName(), associationFQName, entitySetName,
            entitySetFromRole);
  } catch (ODataException e) {
    throw new EdmException(EdmException.PROVIDERPROBLEM, e);
  }

  if (associationSet != null) {
    edmAssociationSet = createAssociationSet(associationSet);
    edmAssociationSets.put(key, edmAssociationSet);
    return edmAssociationSet;
  } else if (edmExtendedEntityContainer != null) {
    edmAssociationSet = edmExtendedEntityContainer.getAssociationSet(sourceEntitySet, navigationProperty);
    edmAssociationSets.put(key, edmAssociationSet);
    return edmAssociationSet;
  } else {
    throw new EdmException(EdmException.COMMON);
  }
}
 
Example 10
Source File: EdmAssociationSetImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmAssociation getAssociation() throws EdmException {
  EdmAssociation association =
      edm.getAssociation(associationSet.getAssociation().getNamespace(), associationSet.getAssociation().getName());
  if (association == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return association;
}
 
Example 11
Source File: EdmEntitySetImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmEntityType getEntityType() throws EdmException {
  if (edmEntityType == null) {
    FullQualifiedName fqName = entitySet.getEntityType();
    edmEntityType = edm.getEntityType(fqName.getNamespace(), fqName.getName());
    if (edmEntityType == null) {
      throw new EdmException(EdmException.COMMON);
    }
  }
  return edmEntityType;
}
 
Example 12
Source File: EdmEntitySetImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmEntitySet getRelatedEntitySet(final EdmNavigationProperty navigationProperty) throws EdmException {
  EdmAssociationSet associationSet =
      edmEntityContainer.getAssociationSet(edmEntityContainer.getEntitySet(entitySet.getName()), navigationProperty);
  EdmAssociationSetEnd toEnd = associationSet.getEnd(navigationProperty.getToRole());
  if (toEnd == null) {
    throw new EdmException(EdmException.COMMON);
  }
  EdmEntitySet targetEntitySet = toEnd.getEntitySet();
  if (targetEntitySet == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return targetEntitySet;
}
 
Example 13
Source File: EdmSimplePropertyImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EdmType getType() throws EdmException {
  if (edmType == null) {
    edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(property.getType());
    if (edmType == null) {
      throw new EdmException(EdmException.COMMON);
    }
  }
  return edmType;
}
 
Example 14
Source File: EdmStructuralTypeImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void resolveBaseType() throws EdmException {
  FullQualifiedName fqName = structuralType.getBaseType();
  if (fqName != null) {
    if (EdmTypeKind.COMPLEX.equals(edmTypeKind)) {
      edmBaseType = edm.getComplexType(fqName.getNamespace(), fqName.getName());
    } else if (EdmTypeKind.ENTITY.equals(edmTypeKind)) {
      edmBaseType = edm.getEntityType(fqName.getNamespace(), fqName.getName());
    }
    if (edmBaseType == null) {
      throw new EdmException(EdmException.COMMON);
    }
  }
}
 
Example 15
Source File: EdmStructuralTypeImplProv.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
protected EdmTyped createProperty(final Property property) throws EdmException {
  if (property instanceof SimpleProperty) {
    return new EdmSimplePropertyImplProv(edm, (SimpleProperty) property);
  } else if (property instanceof ComplexProperty) {
    return new EdmComplexPropertyImplProv(edm, (ComplexProperty) property);
  } else {
    throw new EdmException(EdmException.COMMON);
  }
}