当前位置: 首页>>代码示例>>Java>>正文


Java EdmEntitySet.getEntityType方法代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmEntitySet.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java EdmEntitySet.getEntityType方法的具体用法?Java EdmEntitySet.getEntityType怎么用?Java EdmEntitySet.getEntityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.commons.api.edm.EdmEntitySet的用法示例。


在下文中一共展示了EdmEntitySet.getEntityType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
  final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
  EntityCollection entitySet = readAll(edmEntitySet);
  final List<Entity> entities = entitySet.getEntities();
  final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
  Entity newEntity = new Entity();
  newEntity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
  for (final String keyName : edmEntityType.getKeyPredicateNames()) {
    newEntity.addProperty(DataCreator.createPrimitive(keyName, newKey.get(keyName)));
  }

  createProperties(edmEntityType, newEntity.getProperties());
  try {
    newEntity
        .setId(URI.create(odata.createUriHelper().buildCanonicalURL(edmEntitySet, newEntity)));
  } catch (final SerializerException e) {
    throw new DataProviderException("Unable to set entity ID!", e);
  }
  entities.add(newEntity);

  return newEntity;
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:23,代码来源:DataProvider.java

示例2: handleDeleteSingleNavigationProperties

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
private void handleDeleteSingleNavigationProperties(final EdmEntitySet edmEntitySet,
    final Entity entity, final Entity changedEntity) throws DataProviderException {
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final List<String> navigationPropertyNames = entityType.getNavigationPropertyNames();

  for (final String navPropertyName : navigationPropertyNames) {
    final Link navigationLink = changedEntity.getNavigationLink(navPropertyName);
    final EdmNavigationProperty navigationProperty =
        entityType.getNavigationProperty(navPropertyName);
    if (!navigationProperty.isCollection() && navigationLink != null
        && navigationLink.getInlineEntity() == null) {

      // Check if partner is available
      if (navigationProperty.getPartner() != null
          && entity.getNavigationLink(navPropertyName) != null) {
        Entity partnerEntity = entity.getNavigationLink(navPropertyName).getInlineEntity();
        removeLink(navigationProperty.getPartner(), partnerEntity);
      }

      // Remove link
      removeLink(navigationProperty, entity);
    }
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:25,代码来源:DataProvider.java

示例3: selectMissingId

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
@Test
public void selectMissingId() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  entity.setId(null);
  final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyDate");
  final SelectItem selectItem2 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyBoolean");
  final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
      selectItem1, selectItem2, selectItem2));
    InputStream result = serializer.entity(metadata, entityType, entity,
          EntitySerializerOptions.with()
              .contextURL(ContextURL.with().entitySet(edmEntitySet)
                  .selectList(helper.buildContextURLSelectList(entityType, null, select))
                  .suffix(Suffix.ENTITY).build())
              .select(select)
              .build()).getContent();
        Assert.assertNotNull(result);   
        final String resultString = IOUtils.toString(result);
         Assert.assertEquals(  "{\"@context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","+
         "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\",\"@id\":\"ESAllPrim(32767)\","+
          "\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
        resultString);   
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:ODataJsonSerializerv01Test.java

示例4: updateEntity

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
                          ContentType requestFormat, ContentType responseFormat)
						throws ODataApplicationException, DeserializerException, SerializerException {
	
	// 1. Retrieve the entity set which belongs to the requested entity 
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. update the data in backend
	// 2.1. retrieve the payload from the PUT request for the entity to be updated 
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the modification in backend
	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
	HttpMethod httpMethod = request.getMethod();
	storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
	
	//3. configure the response object
	response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java

示例5: selectMissingId

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
@Test
public void selectMissingId() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  entity.setId(null);
  final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyDate");
  final SelectItem selectItem2 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyBoolean");
  final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
      selectItem1, selectItem2, selectItem2));
    InputStream result = serializer.entity(metadata, entityType, entity,
          EntitySerializerOptions.with()
              .contextURL(ContextURL.with().entitySet(edmEntitySet)
                  .selectList(helper.buildContextURLSelectList(entityType, null, select))
                  .suffix(Suffix.ENTITY).build())
              .select(select)
              .build()).getContent();
        Assert.assertNotNull(result);   
        final String resultString = IOUtils.toString(result);
         Assert.assertEquals(  "{\"@odata.context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","+
         "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"@odata.id\":\"ESAllPrim(32767)\","+
          "\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
        resultString);   
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:ODataJsonSerializerTest.java

示例6: updateEntity

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
@Override
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat,
		ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
	// 1. Retrieve the entity set which belongs to the requested entity
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. update the data in backend
	// 2.1. retrieve the payload from the PUT request for the entity to be updated
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
	HttpMethod httpMethod = request.getMethod();

	try {
		SparqlBaseCommand.updateEntity(rdfEdmProvider, uriInfo, requestEntity, httpMethod);
	} catch (EdmException | OData2SparqlException e) {
		throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
				Locale.ENGLISH);
	}

	//3. configure the response object
	response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:30,代码来源:SparqlEntityProcessor.java

示例7: createEntity

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
@Override
public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat,
		ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
	// 1. Retrieve the entity type from the URI
	EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. create the data in backend
	// 2.1. retrieve the payload from the POST request for the entity to create and deserialize it
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the creation in backend, which returns the newly created entity

	Entity createdEntity = null;
	try {
		createdEntity = SparqlBaseCommand.writeEntity(rdfEdmProvider, uriInfo, requestEntity);
		if (createdEntity == null)
			throw new OData2SparqlException("Entity not created");
	} catch (EdmException | OData2SparqlException e) {
		throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
				Locale.ENGLISH);
	}

	// 3. serialize the response (we have to return the created entity)
	ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build();
	// expand and select currently not supported
	EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build();

	ODataSerializer serializer = this.odata.createSerializer(responseFormat);
	SerializerResult serializedResponse = serializer.entity(serviceMetadata, edmEntityType, createdEntity, options);

	//4. configure the response object
	response.setContent(serializedResponse.getContent());
	response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
	response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:39,代码来源:SparqlEntityProcessor.java

示例8: readEntityCollection

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public void readEntityCollection(ODataRequest request,
		ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
		throws ODataApplicationException, SerializerException {

	// 1st we have retrieve the requested EntitySet from the uriInfo object
	// (representation of the parsed service URI)
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths
			.get(0); // in our example, the first segment is the EntitySet
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();

	// 2nd: fetch the data from backend for this requested EntitySetName //
	// it has to be delivered as EntitySet object
	EntitySet entitySet = getData(uriInfo);

	// 3rd: create a serializer based on the requested format (json)
	ODataFormat format = ODataFormat.fromContentType(responseFormat);
	ODataSerializer serializer = odata.createSerializer(format);

	// 4th: Now serialize the content: transform from the EntitySet object
	// to InputStream
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();
	ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet)
			.build();

	EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions
			.with().contextURL(contextUrl).build();
	InputStream serializedContent = serializer.entityCollection(
			edmEntityType, entitySet, opts);

	// Finally: configure the response object: set the body, headers and
	// status code
	response.setContent(serializedContent);
	response.setStatusCode(HttpStatusCode.OK.getStatusCode());
	response.setHeader(HttpHeader.CONTENT_TYPE,
			responseFormat.toContentTypeString());
}
 
开发者ID:rohitghatol,项目名称:spring-boot-Olingo-oData,代码行数:38,代码来源:GenericEntityCollectionProcessor.java

示例9: EntityList

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public EntityList(String invalidCharacterReplacement, EdmEntitySet edmEntitySet, List<ProjectedColumn> projectedColumns) {
    this.invalidCharacterReplacement = invalidCharacterReplacement;
    this.propertyTypes = new HashMap<String, EdmElement>();
    this.projectedColumns = projectedColumns;

    EdmEntityType entityType = edmEntitySet.getEntityType();
    Iterator<String> propIter = entityType.getPropertyNames().iterator();
    while (propIter.hasNext()) {
        String prop = propIter.next();
        this.propertyTypes.put(prop, entityType.getProperty(prop));
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:13,代码来源:EntityList.java

示例10: update

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public void update(final String rawBaseUri, final EdmEntitySet edmEntitySet, Entity entity,
    final Entity changedEntity, final boolean patch, final boolean isInsert)
        throws DataProviderException {

  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final List<String> keyNames = entityType.getKeyPredicateNames();

  // Update Properties
  for (final String propertyName : entityType.getPropertyNames()) {
    if (!keyNames.contains(propertyName)) {
      updateProperty(entityType.getStructuralProperty(propertyName),
          entity.getProperty(propertyName), changedEntity.getProperty(propertyName), patch);
    }
  }

  // For insert operations collection navigation property bind operations and deep insert
  // operations can be combined.
  // In this case, the bind operations MUST appear before the deep insert operations in the
  // payload.
  // => Apply bindings first
  final boolean navigationBindingsAvailable = !changedEntity.getNavigationBindings().isEmpty();
  if (navigationBindingsAvailable) {
    applyNavigationBinding(rawBaseUri, edmEntitySet, entity,
        changedEntity.getNavigationBindings());
  }

  // Deep insert (only if not an update)
  if (isInsert) {
    handleDeepInsert(rawBaseUri, edmEntitySet, entity, changedEntity);
  } else {
    handleDeleteSingleNavigationProperties(edmEntitySet, entity, changedEntity);
  }

  // Update the ETag if present.
  updateETag(entity);
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:37,代码来源:DataProvider.java

示例11: updateEntityData

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
/**
 * This method is invoked for PATCH or PUT requests
 * */
public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity,
    HttpMethod httpMethod) throws ODataApplicationException {

  EdmEntityType edmEntityType = edmEntitySet.getEntityType();

  // actually, this is only required if we have more than one Entity Type
  if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
    updateProduct(edmEntityType, keyParams, updateEntity, httpMethod);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:Storage.java

示例12: updateEntityData

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
/**
 * This method is invoked for PATCH or PUT requests
 * */
public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity,
    HttpMethod httpMethod) throws ODataApplicationException {

  EdmEntityType edmEntityType = edmEntitySet.getEntityType();

  if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
    updateEntity(edmEntityType, keyParams, updateEntity, httpMethod, productList);
  } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
    updateEntity(edmEntityType, keyParams, updateEntity, httpMethod, categoryList);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:Storage.java

示例13: readEntityData

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams)
    throws ODataApplicationException {

  EdmEntityType edmEntityType = edmEntitySet.getEntityType();
  
  if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
    return getEntity(edmEntityType, keyParams, productList);
  } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
    return getEntity(edmEntityType, keyParams, categoryList);
  } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_ADVERTISEMENTS_NAME)) {
    return getEntity(edmEntityType, keyParams, advertisements);
  }

  return null;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:Storage.java

示例14: readEntityData

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) {
  Entity entity = null;

  EdmEntityType edmEntityType = edmEntitySet.getEntityType();

  if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
    entity = getProduct(edmEntityType, keyParams);
  } else if (edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
    entity = getCategory(edmEntityType, keyParams);
  } else if (edmEntityType.getName().equals(DemoEdmProvider.ET_SUPPLIER_NAME)) {
    entity = getSupplier(edmEntityType, keyParams);
  }

  return entity;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:Storage.java

示例15: createEntity

import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入方法依赖的package包/类
public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
												 ContentType requestFormat, ContentType responseFormat)
			throws ODataApplicationException, DeserializerException, SerializerException {
	
	// 1. Retrieve the entity type from the URI 
	EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. create the data in backend 
	// 2.1. retrieve the payload from the POST request for the entity to create and deserialize it
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the creation in backend, which returns the newly created entity
	Entity createdEntity = storage.createEntityData(edmEntitySet, requestEntity);
	
	// 3. serialize the response (we have to return the created entity)
	ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).build(); 
	EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build(); // expand and select currently not supported 
	
	ODataSerializer serializer = odata.createSerializer(responseFormat);
	SerializerResult serializedResponse = serializer.entity(serviceMetadata, edmEntityType, createdEntity, options);
	
	//4. configure the response object
	response.setContent(serializedResponse.getContent());
	response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
	response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:30,代码来源:DemoEntityProcessor.java


注:本文中的org.apache.olingo.commons.api.edm.EdmEntitySet.getEntityType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。