Java Code Examples for org.apache.olingo.odata2.api.edm.provider.EntitySet#setName()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.EntitySet#setName() . 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: EdmEntitySetInfoImplProvTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
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);

  assertEquals(entitySetName, info.getEntitySetName());
  assertEquals(entitySetUri.toASCIIString(), info.getEntitySetUri().toASCIIString());
  assertEquals(entityContainerName, info.getEntityContainerName());
  assertTrue(info.isDefaultEntityContainer());
}
 
Example 2
Source File: EdmEntitySetInfoImplProvTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
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);

  assertEquals(entitySetName, info.getEntitySetName());
  assertEquals(entitySetUri.toASCIIString(), info.getEntitySetUri().toASCIIString());
  assertEquals(entityContainerName, info.getEntityContainerName());
  assertFalse(info.isDefaultEntityContainer());
}
 
Example 3
Source File: EdmEntitySetInfoImplProvTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void checkValidUTF8Name() throws Exception {
  String entitySetNameOriginal = "Содержание";
  String entitySetNameEscaped = "%D0%A1%D0%BE%D0%B4%D0%B5%D1%80%D0%B6%D0%B0%D0%BD%D0%B8%D0%B5";
  // Write
  EntitySet entitySetRead = new EntitySet();
  entitySetRead.setName(entitySetNameOriginal);
  EntityContainerInfo entityContainerInfo = new EntityContainerInfo().setDefaultEntityContainer(true);

  EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySetRead, entityContainerInfo);

  assertEquals("Содержание", info.getEntitySetName());
  assertEquals(entitySetNameEscaped, info.getEntitySetUri().toASCIIString());

  // Read
  EntitySet entitySetWrite = new EntitySet().setName(Decoder.decode(entitySetNameEscaped));
  EdmEntitySetInfo infoRead = new EdmEntitySetInfoImplProv(entitySetWrite, entityContainerInfo);

  assertEquals(entitySetNameOriginal, infoRead.getEntitySetName());
  assertEquals(entitySetNameEscaped, infoRead.getEntitySetUri().toASCIIString());
}
 
Example 4
Source File: EdmEntitySetInfoImplProvTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void checkValidNameWithoutDefaultContainer() throws Exception {
  String entitySetName = "::Name";
  String entityContainerName = "Container";

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

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

  EdmEntitySetInfo info = new EdmEntitySetInfoImplProv(entitySet, entityContainerInfo);

  assertEquals(entitySetName, info.getEntitySetName());
  assertEquals("Container.%3A%3AName", info.getEntitySetUri().toASCIIString());
  assertEquals(entityContainerName, info.getEntityContainerName());
  assertFalse(info.isDefaultEntityContainer());
}
 
Example 5
Source File: JPAEdmAssociationSetTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: MapProvider.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private void buildSchema() {
  propertyRef = new PropertyRef();
  propertyRef.setName("p1");

  key = new Key();
  key.setKeys(Arrays.asList(propertyRef));

  property1 =
      new SimpleProperty().setName(mapping[P1][EDM]).setType(EdmSimpleTypeKind.String).setMapping(
          new Mapping().setObject(mapping[P1][BACKEND]));
  property2 =
      new SimpleProperty().setName(mapping[P2][EDM]).setType(EdmSimpleTypeKind.String).setMapping(
          new Mapping().setObject(mapping[P2][BACKEND]));
  property3 =
      new SimpleProperty().setName(mapping[P3][EDM]).setType(EdmSimpleTypeKind.String).setMapping(
          new Mapping().setObject(mapping[P3][BACKEND]));

  entityType = new EntityType();
  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();
  entityContainer.setDefaultEntityContainer(true);
  entityContainer.setName(MAPPING_CONTAINER);
  entityContainer.setEntitySets(Arrays.asList(entitySet));

  schema = new Schema();
  schema.setNamespace("mapping");
  schema.setAlias(NAMESPACE);
  schema.setEntityContainers(Arrays.asList(entityContainer));
  schema.setEntityTypes(Arrays.asList(entityType));

  schemas = Arrays.asList(schema);
}