Package org.apache.olingo.odata2.api.edm.provider

Examples of org.apache.olingo.odata2.api.edm.provider.EntitySet


  @Override
  public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataMessageException {
    if (ENTITY_CONTAINER_1.equals(entityContainer)) {
      if (ES_KEY_IS_STRING.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ET_KEY_IS_STRING);
      } else if (ES_KEY_IS_INTEGER.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ET_KEY_IS_INTEGER);
      } else if (ES_COMPLEX_KEY.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ET_COMPLEX_KEY);
      } else if (ES_ALL_TYPES.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ET_ALL_TYPES);
      } else if (ES_STRING_FACETS.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ET_STRING_FACETS);
      }
    }

    return null;
  }
View Full Code Here


    EdmEntitySet edmEntitySet = edmEntitySets.get(name);
    if (edmEntitySet != null) {
      return edmEntitySet;
    }

    EntitySet entitySet;
    try {
      entitySet = edm.edmProvider.getEntitySet(entityContainer.getName(), name);
    } catch (ODataException e) {
      throw new EdmException(EdmException.PROVIDERPROBLEM, e);
    }
View Full Code Here

  @Override
  public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException {
    if (ENTITY_CONTAINER_1.equals(entityContainer)) {
      if (ENTITY_SET_1_1.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_1);
      } else if (ENTITY_SET_1_2.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_2);
      } else if (ENTITY_SET_1_3.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_3);
      } else if (ENTITY_SET_1_4.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_4);
      } else if (ENTITY_SET_1_5.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_5);
      }

    } else if (ENTITY_CONTAINER_2.equals(entityContainer)) {
      if (ENTITY_SET_2_1.equals(name)) {
        return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_2_1);
      }
    }

    return null;
  }
View Full Code Here

    EntityContainerInfo entityContainer = new EntityContainerInfo().setName("Container");
    when(edmProvider.getEntityContainerInfo("Container")).thenReturn(entityContainer);
    EdmEntityContainerImplProv edmEntityContainer = new EdmEntityContainerImplProv(edmImplProv, entityContainer);

    EntitySet entitySetFoo = new EntitySet().setName("foo");
    when(edmProvider.getEntitySet("Container", "foo")).thenReturn(entitySetFoo);

    List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
    FullQualifiedName fooBarAssocName = new FullQualifiedName("namespace", "fooBarAssoc");
    navigationProperties.add(new NavigationProperty().setName("fooBarNav").setFromRole("fromFoo").setRelationship(
        fooBarAssocName).setToRole("toBar"));

    EntityType fooEntityType = new EntityType().setName("fooEntityType").setNavigationProperties(navigationProperties);
    FullQualifiedName fooEntityTypeFullName = new FullQualifiedName("namespace", "fooEntityType");
    entitySetFoo.setEntityType(fooEntityTypeFullName);
    when(edmProvider.getEntityType(fooEntityTypeFullName)).thenReturn(fooEntityType);

    EntitySet entitySetBar = new EntitySet().setName("bar");
    when(edmProvider.getEntitySet("Container", "bar")).thenReturn(entitySetBar);

    EntityType barEntityType = new EntityType().setName("barEntityType");
    FullQualifiedName barEntityTypeFullName = new FullQualifiedName("namespace", "barEntityType");
    entitySetBar.setEntityType(barEntityTypeFullName);
    when(edmProvider.getEntityType(barEntityTypeFullName)).thenReturn(barEntityType);

    AssociationEnd fooEnd = new AssociationEnd().setRole("fromFoo");
    AssociationEnd barEnd = new AssociationEnd().setRole("toBar");
View Full Code Here

  public void entityWithDefaultContainer() throws Exception {
    String entitySetName = "Employees";
    URI entitySetUri = new URI(entitySetName);
    String entityContainerName = "Container";

    EntitySet entitySet = new EntitySet();
    entitySet.setName(entitySetName);

    EntityContainerInfo entityContainerInfo = new EntityContainerInfo();
    entityContainerInfo.setName(entityContainerName).setDefaultEntityContainer(true);

    EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySet, entityContainerInfo);
View Full Code Here

  public void entityWithoutDefaultContainer() throws Exception {
    String entitySetName = "Employees";
    String entityContainerName = "Container";
    URI entitySetUri = new URI(entityContainerName + "." + entitySetName);

    EntitySet entitySet = new EntitySet();
    entitySet.setName(entitySetName);

    EntityContainerInfo entityContainerInfo = new EntityContainerInfo();
    entityContainerInfo.setName(entityContainerName).setDefaultEntityContainer(false);

    EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySet, entityContainerInfo);
View Full Code Here

    return associationSet;
  }

  private EntitySet readEntitySet(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
    reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ENTITY_SET);
    EntitySet entitySet = new EntitySet();
    List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
    entitySet.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
    String entityType = reader.getAttributeValue(null, XmlMetadataConstants.EDM_ENTITY_TYPE);
    if (entityType != null) {
      FullQualifiedName fqName = extractFQName(entityType);
      entitySet.setEntityType(fqName);
    } else {
      throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE
          .addContent(XmlMetadataConstants.EDM_ENTITY_TYPE).addContent(XmlMetadataConstants.EDM_ENTITY_SET));
    }
    entitySet.setAnnotationAttributes(readAnnotationAttribute(reader));
    while (reader.hasNext()
        && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
        && XmlMetadataConstants.EDM_ENTITY_SET.equals(reader.getLocalName()))) {
      reader.next();
      if (reader.isStartElement()) {
        extractNamespaces(reader);
        annotationElements.add(readAnnotationElement(reader));
      }
    }
    if (!annotationElements.isEmpty()) {
      entitySet.setAnnotationElements(annotationElements);
    }
    return entitySet;
  }
View Full Code Here

  }

  private List<EntitySet> getEntitySetListLocal() {
    List<EntitySet> entitySetList = new ArrayList<EntitySet>();

    EntitySet entitySet = new EntitySet();
    entitySet.setName("SalesOrderHeader");
    entitySet.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));

    EntitySet entitySet2 = new EntitySet();
    entitySet2.setName("SalesOrderItem");
    entitySet2.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));

    entitySetList.add(entitySet);
    entitySetList.add(entitySet2);
    return entitySetList;
  }
View Full Code Here

    entityType.setName(mapping[ENTITYTYPE][EDM]);
    entityType.setKey(key);
    entityType.setProperties(Arrays.asList(property1, property2, property3));
    entityType.setMapping(new Mapping().setObject(mapping[ENTITYTYPE][BACKEND]));

    entitySet = new EntitySet();
    entitySet.setName(mapping[ENTITYSET][EDM]);
    entitySet.setEntityType(new FullQualifiedName(NAMESPACE, mapping[ENTITYTYPE][EDM]));
    entitySet.setMapping(new Mapping().setObject(mapping[ENTITYSET][BACKEND]));

    entityContainer = new EntityContainer();
View Full Code Here

  }

  @Test
  public void entitySetTeams() throws Exception {
    // validate teams
    EntitySet teams = aep.getEntitySet(ModelSharedConstants.CONTAINER_1, "Teams");
    assertEquals(ModelSharedConstants.NAMESPACE_1, teams.getEntityType().getNamespace());
    assertEquals("Team", teams.getEntityType().getName());
  }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.provider.EntitySet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.