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


Java Entity.setType方法代码示例

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


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

示例1: create

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的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: getStoredPI

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@GET
@Path("/StoredPIs(1000)")
public Response getStoredPI(@Context final UriInfo uriInfo) {
  final Entity entity = new Entity();
  entity.setType("Microsoft.Test.OData.Services.ODataWCFService.StoredPI");
  final Property id = new Property();
  id.setType("Edm.Int32");
  id.setName("StoredPIID");
  id.setValue(ValueType.PRIMITIVE, 1000);
  entity.getProperties().add(id);
  final Link edit = new Link();
  edit.setHref(uriInfo.getRequestUri().toASCIIString());
  edit.setRel("edit");
  edit.setTitle("StoredPI");
  entity.setEditLink(edit);

  final ByteArrayOutputStream content = new ByteArrayOutputStream();
  final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
  try {
    jsonSerializer.write(writer, new ResWrap<Entity>((URI) null, null, entity));
    return xml.createResponse(new ByteArrayInputStream(content.toByteArray()), null, Accept.JSON_FULLMETA);
  } catch (Exception e) {
    LOG.error("While creating StoredPI", e);
    return xml.createFaultResponse(Accept.JSON_FULLMETA.toString(), e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:Services.java

示例3: create

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的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, edmEntityType);
  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!", HttpStatusCode.INTERNAL_SERVER_ERROR, e);
  }
  entities.add(newEntity);

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

示例4: consumeEntityNode

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private Entity consumeEntityNode(final EdmEntityType edmEntityType, final ObjectNode tree,
    final ExpandTreeBuilder expandBuilder) throws DeserializerException {
  Entity entity = new Entity();
  entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());

  // Check and consume all Properties
  consumeEntityProperties(edmEntityType, tree, entity);

  // Check and consume all expanded Navigation Properties
  consumeExpandedNavigationProperties(edmEntityType, tree, entity, expandBuilder);

  // consume remaining json node fields
  consumeRemainingJsonNodeFields(edmEntityType, tree, entity);

  assertJsonNodeIsEmpty(tree);

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

示例5: createEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private Entity createEntity(EdmEntitySet edmEntitySet, EdmEntityType edmEntityType, Entity entity, 
    List<Entity> entityList, final String rawServiceUri) throws ODataApplicationException {
  
  // 1.) Create the entity
  final Entity newEntity = new Entity();
  newEntity.setType(entity.getType());
  
  // Create the new key of the entity
  int newId = 1;
  while (entityIdExists(newId, entityList)) {
    newId++;
  }
  
  // Add all provided properties
  newEntity.getProperties().addAll(entity.getProperties());
  
  // Add the key property
  newEntity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
  newEntity.setId(createId(newEntity, "ID"));
  
  // --> Implement Deep Insert handling here <--
  
  entityList.add(newEntity);

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

示例6: createManufacturers

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private EntityCollection createManufacturers() {
  EntityCollection entitySet = new EntityCollection();

  Entity el = new Entity()
      .addProperty(createPrimitive("Id", 1))
      .addProperty(createPrimitive("Name", "Star Powered Racing"))
      .addProperty(createAddress("Star Street 137", "Stuttgart", "70173", "Germany"));
  el.setId(createId(CarsEdmProvider.ES_MANUFACTURER_NAME, 1));
  entitySet.getEntities().add(el);

  el = new Entity()
      .addProperty(createPrimitive("Id", 2))
      .addProperty(createPrimitive("Name", "Horse Powered Racing"))
      .addProperty(createAddress("Horse Street 1", "Maranello", "41053", "Italy"));
  el.setId(createId(CarsEdmProvider.ES_MANUFACTURER_NAME, 2));
  entitySet.getEntities().add(el);

  for (Entity entity:entitySet.getEntities()) {
    entity.setType(CarsEdmProvider.ET_MANUFACTURER.getFullQualifiedNameAsString());
  }
  return entitySet;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:DataProvider.java

示例7: createESTwoPrimDerived

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private EntityCollection createESTwoPrimDerived(final Edm edm, final OData odata) {
  EntityCollection entityCollection = new EntityCollection();

  entityCollection.getEntities().add(new Entity()
      .addProperty(createPrimitive("PropertyInt16", (short) -365))
      .addProperty(createPrimitive("PropertyString", "Test String2")));

  entityCollection.getEntities().add(new Entity()
      .addProperty(createPrimitive("PropertyInt16", (short) -32766))
      .addProperty(createPrimitive("PropertyString", null)));

  entityCollection.getEntities().add(new Entity()
      .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
      .addProperty(createPrimitive("PropertyString", "Test String4")));

  setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETTwoPrim));
  
  Entity derivedEntity = new Entity()
      .addProperty(createPrimitive("PropertyInt16", (short) 32766))
      .addProperty(createPrimitive("PropertyString", "Test String1"))
      .addProperty(createPrimitive("AdditionalPropertyString_5", "Additional String1"));
      derivedEntity.setType(EntityTypeProvider.nameETBase.getFullQualifiedNameAsString());
      entityCollection.getEntities().add(derivedEntity);
      
  createEntityId(edm, odata, "ESTwoPrimDerived", entityCollection);
  createOperations("ESTwoPrimDerived", entityCollection, EntityTypeProvider.nameETTwoPrim);
  return entityCollection;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:DataCreator.java

示例8: copyAnnotations

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private void copyAnnotations(Entity inlineEntity, ComplexValue complex) {
  for (Annotation annotation:complex.getAnnotations()) {
    if (annotation.getTerm().equals(Constants.JSON_TYPE.substring(1))){
      inlineEntity.setType((String)annotation.asPrimitive());
    } else if (annotation.getTerm().equals(Constants.JSON_ID.substring(1))){
      inlineEntity.setId(URI.create((String)annotation.asPrimitive()));
    } else if (annotation.getTerm().equals(Constants.JSON_ETAG.substring(1))){
      inlineEntity.setETag((String)annotation.asPrimitive());
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:ODataBinderImpl.java

示例9: copyEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private Entity copyEntity(final Entity entity) {
  final Entity newEntity = new Entity();
  newEntity.setBaseURI(entity.getBaseURI());
  newEntity.setEditLink(entity.getEditLink());
  newEntity.setETag(entity.getETag());
  newEntity.setId(entity.getId());
  newEntity.setMediaContentSource(entity.getMediaContentSource());
  newEntity.setMediaContentType(entity.getMediaContentType());
  newEntity.setSelfLink(entity.getSelfLink());
  newEntity.setMediaETag(entity.getMediaETag());
  newEntity.setType(entity.getType());
  newEntity.getProperties().addAll(entity.getProperties());
  
  return newEntity;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:TransactionalEntityManager.java

示例10: setEntityType

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private void setEntityType(EntityCollection entityCollection, final EdmEntityType type) {
  for (Entity entity : entityCollection.getEntities()) {
    entity.setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:6,代码来源:DataCreator.java

示例11: functionGetProductDetails

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@GET
@Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails({param:.*})")
public Response functionGetProductDetails(
    @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
    @PathParam("entityId") final String entityId,
    @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {

  try {
    final Accept acceptType;
    if (StringUtils.isNotBlank(format)) {
      acceptType = Accept.valueOf(format.toUpperCase());
    } else {
      acceptType = Accept.parse(accept);
    }

    final Entity entry = new Entity();
    entry.setType("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail");
    final Property productId = new Property();
    productId.setName("ProductID");
    productId.setType("Edm.Int32");
    productId.setValue(ValueType.PRIMITIVE, Integer.valueOf(entityId));
    entry.getProperties().add(productId);
    final Property productDetailId = new Property();
    productDetailId.setName("ProductDetailID");
    productDetailId.setType("Edm.Int32");
    productDetailId.setValue(ValueType.PRIMITIVE, 2);
    entry.getProperties().add(productDetailId);

    final Link link = new Link();
    link.setRel("edit");
    link.setHref(URI.create(
        Constants.get(ConstantKey.DEFAULT_SERVICE_URL)
            + "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
    entry.setEditLink(link);

    final EntityCollection feed = new EntityCollection();
    feed.getEntities().add(entry);

    final ResWrap<EntityCollection> container = new ResWrap<EntityCollection>(
        URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
        feed);

    return xml.createResponse(
        null,
        xml.writeEntitySet(acceptType, container),
        null,
        acceptType);
  } catch (Exception e) {
    return xml.createFaultResponse(accept, e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:52,代码来源:Services.java

示例12: getEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Override
public Entity getEntity(final ClientEntity odataEntity) {
  final Entity entity = new Entity();

  entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());

  // -------------------------------------------------------------
  // Add edit and self link
  // -------------------------------------------------------------
  final URI odataEditLink = odataEntity.getEditLink();
  if (odataEditLink != null) {
    final Link editLink = new Link();
    editLink.setTitle(entity.getType());
    editLink.setHref(odataEditLink.toASCIIString());
    editLink.setRel(Constants.EDIT_LINK_REL);
    entity.setEditLink(editLink);
  }

  if (odataEntity.isReadOnly()) {
    final Link selfLink = new Link();
    selfLink.setTitle(entity.getType());
    selfLink.setHref(odataEntity.getLink().toASCIIString());
    selfLink.setRel(Constants.SELF_LINK_REL);
    entity.setSelfLink(selfLink);
  }
  // -------------------------------------------------------------

  links(odataEntity, entity);

  // -------------------------------------------------------------
  // Append edit-media links
  // -------------------------------------------------------------
  for (ClientLink link : odataEntity.getMediaEditLinks()) {
    LOG.debug("Append edit-media link\n{}", link);
    entity.getMediaEditLinks().add(getLink(link));
  }
  // -------------------------------------------------------------

  if (odataEntity.isMediaEntity()) {
    entity.setMediaContentSource(odataEntity.getMediaContentSource());
    entity.setMediaContentType(odataEntity.getMediaContentType());
    entity.setMediaETag(odataEntity.getMediaETag());
  }

  for (ClientProperty property : odataEntity.getProperties()) {
    entity.getProperties().add(getProperty(property));
  }

  entity.setId(odataEntity.getId());
  annotations(odataEntity, entity);
  return entity;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:53,代码来源:ODataBinderImpl.java

示例13: createCars

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private EntityCollection createCars() {
  EntityCollection entitySet = new EntityCollection();
  Entity el = new Entity()
      .addProperty(createPrimitive("Id", 1))
      .addProperty(createPrimitive("Model", "F1 W03"))
      .addProperty(createPrimitive("ModelYear", "2012"))
      .addProperty(createPrimitive("Price", 189189.43))
      .addProperty(createPrimitive("Currency", "EUR"));
  el.setId(createId(CarsEdmProvider.ES_CARS_NAME, 1));
  entitySet.getEntities().add(el);

  el = new Entity()
      .addProperty(createPrimitive("Id", 2))
      .addProperty(createPrimitive("Model", "F1 W04"))
      .addProperty(createPrimitive("ModelYear", "2013"))
      .addProperty(createPrimitive("Price", 199999.99))
      .addProperty(createPrimitive("Currency", "EUR"));
  el.setId(createId(CarsEdmProvider.ES_CARS_NAME, 2));
  entitySet.getEntities().add(el);

  el = new Entity()
      .addProperty(createPrimitive("Id", 3))
      .addProperty(createPrimitive("Model", "F2012"))
      .addProperty(createPrimitive("ModelYear", "2012"))
      .addProperty(createPrimitive("Price", 137285.33))
      .addProperty(createPrimitive("Currency", "EUR"));
  el.setId(createId(CarsEdmProvider.ES_CARS_NAME, 3));
  entitySet.getEntities().add(el);

  el = new Entity()
      .addProperty(createPrimitive("Id", 4))
      .addProperty(createPrimitive("Model", "F2013"))
      .addProperty(createPrimitive("ModelYear", "2013"))
      .addProperty(createPrimitive("Price", 145285.00))
      .addProperty(createPrimitive("Currency", "EUR"));
  el.setId(createId(CarsEdmProvider.ES_CARS_NAME, 4));
  entitySet.getEntities().add(el);

  el = new Entity()
      .addProperty(createPrimitive("Id", 5))
      .addProperty(createPrimitive("Model", "F1 W02"))
      .addProperty(createPrimitive("ModelYear", "2011"))
      .addProperty(createPrimitive("Price", 167189.00))
      .addProperty(createPrimitive("Currency", "EUR"));
  el.setId(createId(CarsEdmProvider.ES_CARS_NAME, 5));
  entitySet.getEntities().add(el);

  for (Entity entity:entitySet.getEntities()) {
    entity.setType(CarsEdmProvider.ET_CAR.getFullQualifiedNameAsString());
  }
  return entitySet;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:53,代码来源:DataProvider.java


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