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

The following examples show how to use org.apache.olingo.odata2.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: Model.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Association getAssociation(FullQualifiedName edm_fq_name) throws ODataException
{
   if (edm_fq_name != null && edm_fq_name.getNamespace().equals(NAMESPACE))
   {
      String assocName = edm_fq_name.getName();
      String entity = assocName.substring(0, assocName.indexOf("_"));
      for (Association assoc: ENTITYSETS.get(AbstractEntitySet.generateEntitySetName(entity)).getAssociations())
      {
         if (assoc.getName().equals(edm_fq_name.getName()))
         {
            return assoc;
         }
      }
   }
   return null;
}
 
Example 2
Source File: Model.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public AssociationSet getAssociationSet(String entity_container,
      FullQualifiedName association, String source_entity_set_name,
      String source_entity_set_role) throws ODataException
{
   if (association == null || association.getName() == null)
   {
      return null;
   }
   if (entity_container == null || entity_container.equals(ENTITY_CONTAINER))
   {
      for (AssociationSet assoc: ENTITYSETS.get(source_entity_set_name).getAssociationSets())
      {
         if (assoc.getName().equals(association.getName()))
         {
            return assoc;
         }
      }
   }
   return null;
}
 
Example 3
Source File: JPAEdmNameBuilder.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public static void build(final JPAEdmEntitySetView view, final JPAEdmEntityTypeView entityTypeView) {
  FullQualifiedName fQname = view.getEdmEntitySet().getEntityType();
  JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
  String entitySetName = null;
  if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
    Mapping mapping = entityTypeView.getEdmEntityType().getMapping();
    if (mapping != null) {
      entitySetName = mappingModelAccess.mapJPAEntitySet(mapping.getInternalName());
    }
  }

  if (entitySetName == null) {
    entitySetName = fQname.getName() + ENTITY_SET_SUFFIX;
  }

  view.getEdmEntitySet().setName(entitySetName);
}
 
Example 4
Source File: XmlMetadataDeserializer.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void setBaseTypeForComplexType() throws EdmException {
  for (Entry<FullQualifiedName, EdmComplexType> entity : complexTypesMap.entrySet()) {
    EdmComplexTypeImpl entityType = (EdmComplexTypeImpl) entity.getValue();
    if (((EdmComplexTypeImpl) entity.getValue()).getEdmBaseTypeName() != null && 
        entity.getValue().getBaseType() == null) {
      FullQualifiedName fqname = entityType.getEdmBaseTypeName();
      if(complexTypesMap.get(entityType.getEdmBaseTypeName()) != null){
        entityType.setEdmBaseType(complexTypesMap.get(fqname));
      }else if (aliasNamespaceMap.containsKey(fqname.getNamespace())) {
        FullQualifiedName changedName = new FullQualifiedName(
            aliasNamespaceMap.get(fqname.getNamespace()), fqname.getName());
        entityType.setEdmBaseType(complexTypesMap.get(changedName));
      }else{
        //Adding dummy basetype awhich will fail during validation
        EdmComplexTypeImpl newBaseType = new EdmComplexTypeImpl();
        newBaseType.setName(fqname.getName());
        newBaseType.setNamespace(fqname.getNamespace());
        ((EdmComplexTypeImpl) entity.getValue()).setEdmBaseType(newBaseType);
         break;
      }
      
    }
  }
  setBaseTypePropertiesForComplexType(complexBaseTypeMap);
}
 
Example 5
Source File: XmlMetadataDeserializer.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void setBaseTypeForEntityType() throws EdmException {
  for (Entry<FullQualifiedName, EdmEntityType> entity : entityTypesMap.entrySet()) {
    EdmEntityTypeImpl entityType = (EdmEntityTypeImpl) entity.getValue();
    if (entityType.getBaseTypeName() != null && entity.getValue()
        .getBaseType() == null) {
      FullQualifiedName fqname = entityType.getBaseTypeName();
      if (entityTypesMap.get(entityType.getBaseTypeName()) != null) {
        entityType.setEdmBaseType(entityTypesMap.get(fqname));
      } else if (aliasNamespaceMap.containsKey(fqname.getNamespace())) {
        FullQualifiedName changedName = new FullQualifiedName(
            aliasNamespaceMap.get(fqname.getNamespace()), fqname.getName());
        entityType.setEdmBaseType(entityTypesMap.get(changedName));
      } else {// Adding dummy basetype which will fail during validation
        EdmEntityTypeImpl newBaseType = new EdmEntityTypeImpl();
        newBaseType.setName(fqname.getName());
        newBaseType.setNamespace(fqname.getNamespace());
        entityType.setEdmBaseType(newBaseType);
        break;
      }
    }
  }
  setBaseTypePropertiesForEntityType(entityBaseTypeMap);
}
 
Example 6
Source File: ODataJPAEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException {

  String strEdmFQName = null;

  if (edmFQName != null) {
    strEdmFQName = edmFQName.toString();
    if (entityTypes.containsKey(strEdmFQName)) {
      return entityTypes.get(strEdmFQName);
    } else if (schemas == null) {
      getSchemas();
    }

    String entityTypeNamespace = edmFQName.getNamespace();
    String entityTypeName = edmFQName.getName();

    for (Schema schema : schemas) {
      String schemaNamespace = schema.getNamespace();
      if (schemaNamespace.equals(entityTypeNamespace)) {
        if (schema.getEntityTypes() == null) {
          return null;
        }
        for (EntityType et : schema.getEntityTypes()) {
          if (et.getName().equals(entityTypeName)) {
            entityTypes.put(strEdmFQName, et);
            return et;
          }
        }
      }
    }
  }

  return null;
}
 
Example 7
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private FullQualifiedName validateEntityTypeWithAlias(final FullQualifiedName aliasName)
    throws EntityProviderException {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!entityTypesMap.containsKey(fqName)) {
    throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid Type"));
  }
  return fqName;
}
 
Example 8
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private FullQualifiedName validateComplexTypeWithAlias(final FullQualifiedName aliasName)
    throws EntityProviderException {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!complexTypesMap.containsKey(fqName)) {
    throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid BaseType")
        .addContent(fqName));
  }
  return fqName;
}
 
Example 9
Source File: XmlMetadataDeserializer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private FullQualifiedName validateEntityTypeWithAlias(final FullQualifiedName aliasName)
    throws EntityProviderException {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!entityTypesMap.containsKey(fqName)) {
    throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid Type"));
  }
  return fqName;
}
 
Example 10
Source File: XmlMetadataDeserializer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private FullQualifiedName validateComplexTypeWithAlias(final FullQualifiedName aliasName)
    throws EntityProviderException {
  String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
  FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
  if (!complexTypesMap.containsKey(fqName)) {
    throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid BaseType")
        .addContent(fqName));
  }
  return fqName;
}
 
Example 11
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public TypeBuilder(final FullQualifiedName fqn) {
  namespace = fqn.getNamespace();
  name = fqn.getName();
}
 
Example 12
Source File: JPAEdmComplexType.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public ComplexType searchEdmComplexType(final FullQualifiedName type) {
  String name = type.getName();
  return searchComplexTypeByName(name);

}