本文整理汇总了Java中org.apache.olingo.commons.api.data.Entity.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getType方法的具体用法?Java Entity.getType怎么用?Java Entity.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.data.Entity
的用法示例。
在下文中一共展示了Entity.getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的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 = changedEntity.getType()!=null ?
edm.getEntityType(new FullQualifiedName(changedEntity.getType())):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);
}
示例2: doSerialize
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
protected void doSerialize(final EdmEntityType entityType, final Entity entity,
final String contextURLString, final String metadataETag, JsonGenerator json)
throws IOException, SerializerException {
json.writeStartObject();
final String typeName = entity.getType() == null ? null : new EdmTypeInfo.Builder().setTypeExpression(entity
.getType()).build().external();
metadata(contextURLString, metadataETag, entity.getETag(), typeName, entity.getId(), true, json);
for (final Annotation annotation : entity.getAnnotations()) {
valuable(json, annotation, '@' + annotation.getTerm(), null, null);
}
for (final Property property : entity.getProperties()) {
final String name = property.getName();
final EdmProperty edmProperty = entityType == null || entityType.getStructuralProperty(name) == null ? null
: entityType.getStructuralProperty(name);
valuable(json, property, name, edmProperty == null ? null : edmProperty.getType(), edmProperty);
}
if (!isODataMetadataNone &&
entity.getEditLink() != null && entity.getEditLink().getHref() != null) {
json.writeStringField(Constants.JSON_EDIT_LINK, entity.getEditLink().getHref());
if (entity.isMediaEntity()) {
json.writeStringField(Constants.JSON_MEDIA_READ_LINK, entity.getEditLink().getHref() + "/$value");
}
}
links(entity, entityType, json);
json.writeEndObject();
}
示例3: getEntitySetName
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private String getEntitySetName(Entity entity) {
if(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_CATEGORIES_NAME;
} else if(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_PRODUCTS_NAME;
}
return entity.getType();
}
示例4: getRelatedEntityCollection
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public EntityCollection getRelatedEntityCollection(Entity sourceEntity, EdmEntityType targetEntityType) {
EntityCollection navigationTargetEntityCollection = new EntityCollection();
FullQualifiedName relatedEntityFqn = targetEntityType.getFullQualifiedName();
String sourceEntityFqn = sourceEntity.getType();
if (sourceEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString())
&& relatedEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN)) {
// relation Products->Category (result all categories)
int productID = (Integer) sourceEntity.getProperty("ID").getValue();
if (productID == 0 || productID == 1) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(0));
} else if (productID == 2 || productID == 3) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(1));
} else if (productID == 4 || productID == 5) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(2));
}
} else if (sourceEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString())
&& relatedEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN)) {
// relation Category->Products (result all products)
int categoryID = (Integer) sourceEntity.getProperty("ID").getValue();
if (categoryID == 0) {
// the first 2 products are notebooks
navigationTargetEntityCollection.getEntities().addAll(productList.subList(0, 2));
} else if (categoryID == 1) {
// the next 2 products are organizers
navigationTargetEntityCollection.getEntities().addAll(productList.subList(2, 4));
} else if (categoryID == 2) {
// the first 2 products are monitors
navigationTargetEntityCollection.getEntities().addAll(productList.subList(4, 6));
}
}
return navigationTargetEntityCollection;
}
示例5: getEntitySetName
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private String getEntitySetName(Entity entity) {
if(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_CATEGORIES_NAME;
} else if(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_PRODUCTS_NAME;
} else if (DemoEdmProvider.ET_ADVERTISEMENT_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_ADVERTISEMENTS_NAME;
}
return entity.getType();
}
示例6: getEntitySetName
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private String getEntitySetName(Entity entity) {
if (DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_CATEGORIES_NAME;
} else if (DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_PRODUCTS_NAME;
} else if (DemoEdmProvider.ET_ADVERTISEMENT_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_ADVERTISEMENTS_NAME;
}
return entity.getType();
}
示例7: getEntitySetName
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private String getEntitySetName(Entity entity) {
if(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_CATEGORIES_NAME;
} else if(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_PRODUCTS_NAME;
} else if(DemoEdmProvider.ET_SUPPLIER_FQN.getFullQualifiedNameAsString().equals(entity.getType())) {
return DemoEdmProvider.ES_PRODUCTS_NAME;
}
return entity.getType();
}
示例8: doContainerSerialize
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
throws IOException, EdmPrimitiveTypeException {
final Entity entity = container.getPayload();
jgen.writeStartObject();
if (serverMode) {
if (container.getContextURL() != null) {
jgen.writeStringField(Constants.JSON_CONTEXT, container.getContextURL().toASCIIString());
}
if (container.getMetadataETag() != null) {
jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
}
if (entity.getETag() != null) {
jgen.writeStringField(Constants.JSON_ETAG, entity.getETag());
}
}
if (entity.getType() != null && !isODataMetadataNone) {
jgen.writeStringField(Constants.JSON_TYPE,
new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
}
if (entity.getId() != null && !isODataMetadataNone) {
jgen.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
}
for (Annotation annotation : entity.getAnnotations()) {
valuable(jgen, annotation, "@" + annotation.getTerm());
}
for (Property property : entity.getProperties()) {
valuable(jgen, property, property.getName());
}
if (serverMode && entity.getEditLink() != null && entity.getEditLink().getHref() != null) {
jgen.writeStringField(Constants.JSON_EDIT_LINK, entity.getEditLink().getHref());
if (entity.isMediaEntity()) {
jgen.writeStringField(Constants.JSON_MEDIA_READ_LINK,
entity.getEditLink().getHref() + "/$value");
}
}
if (!isODataMetadataNone) {
links(entity, jgen);
}
for (Link link : entity.getMediaEditLinks()) {
if (link.getTitle() == null) {
jgen.writeStringField(Constants.JSON_MEDIA_EDIT_LINK, link.getHref());
}
if (link.getInlineEntity() != null) {
jgen.writeObjectField(link.getTitle(), link.getInlineEntity());
}
if (link.getInlineEntitySet() != null) {
jgen.writeArrayFieldStart(link.getTitle());
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
jgen.writeObject(subEntry);
}
jgen.writeEndArray();
}
}
if (serverMode) {
for (Operation operation : entity.getOperations()) {
final String anchor = operation.getMetadataAnchor();
final int index = anchor.lastIndexOf('#');
jgen.writeObjectFieldStart('#' + anchor.substring(index < 0 ? 0 : (index + 1)));
jgen.writeStringField(Constants.ATTR_TITLE, operation.getTitle());
jgen.writeStringField(Constants.ATTR_TARGET, operation.getTarget().toASCIIString());
jgen.writeEndObject();
}
}
jgen.writeEndObject();
}
示例9: getRelatedEntityCollection
import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
public EntityCollection getRelatedEntityCollection(Entity sourceEntity, EdmEntityType targetEntityType) {
EntityCollection navigationTargetEntityCollection = new EntityCollection();
FullQualifiedName relatedEntityFqn = targetEntityType.getFullQualifiedName();
String sourceEntityFqn = sourceEntity.getType();
if (sourceEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString())
&& relatedEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN)) {
navigationTargetEntityCollection.setId(createId(sourceEntity, "ID", DemoEdmProvider.NAV_TO_CATEGORY));
// relation Products->Category (result all categories)
int productID = (Integer) sourceEntity.getProperty("ID").getValue();
if (productID == 1 || productID == 2) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(0));
} else if (productID == 3 || productID == 4) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(1));
} else if (productID == 5 || productID == 6) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(2));
}
} else if (sourceEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString())
&& relatedEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN)) {
navigationTargetEntityCollection.setId(createId(sourceEntity, "ID", DemoEdmProvider.NAV_TO_PRODUCTS));
// relation Category->Products (result all products)
int categoryID = (Integer) sourceEntity.getProperty("ID").getValue();
if (categoryID == 1) {
// the first 2 products are notebooks
navigationTargetEntityCollection.getEntities().addAll(productList.subList(0, 2));
} else if (categoryID == 2) {
// the next 2 products are organizers
navigationTargetEntityCollection.getEntities().addAll(productList.subList(2, 4));
} else if (categoryID == 3) {
// the first 2 products are monitors
navigationTargetEntityCollection.getEntities().addAll(productList.subList(4, 6));
}
}
if (navigationTargetEntityCollection.getEntities().isEmpty()) {
return null;
}
return navigationTargetEntityCollection;
}