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


Java UriResource类代码示例

本文整理汇总了Java中org.apache.olingo.server.api.uri.UriResource的典型用法代码示例。如果您正苦于以下问题:Java UriResource类的具体用法?Java UriResource怎么用?Java UriResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toSort

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
/**
 * Converts {@link OrderByItem} to {@link Sort} needed for
 * {@link Pagination}.
 * 
 * @param orderByItem
 *            order by item
 * @return sort instance, or null in case order by item wasn't specific type
 */
protected Sort toSort(OrderByItem orderByItem) {
    Expression expression = orderByItem.getExpression();
    if (expression instanceof Member) {
        UriInfoResource resourcePath = ((Member) expression).getResourcePath();
        UriResource uriResource = resourcePath.getUriResourceParts().get(0);
        if (uriResource instanceof UriResourcePrimitiveProperty) {
            EdmProperty edmProperty = ((UriResourcePrimitiveProperty) uriResource)
                    .getProperty();
            String property = edmProperty.getName();
            if (edmProperty instanceof ElasticEdmProperty) {
                ElasticEdmProperty entityTypeProperty = (ElasticEdmProperty) edmProperty;
                property = addKeywordIfNeeded(entityTypeProperty.getEField(),
                        entityTypeProperty.getAnnotations());
            }
            return new Sort(property,
                    orderByItem.isDescending() ? Sort.Direction.DESC : Sort.Direction.ASC);
        }
    }
    return null;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:29,代码来源:RequestCreator.java

示例2: readReferenceCollection

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
static public EntityCollection readReferenceCollection(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
		UriType uriType) throws OData2SparqlException, EdmException, ODataApplicationException, ExpressionVisitException {
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	RdfEntityType rdfEntityType = null;
	EdmEntitySet edmEntitySet = null;

	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
	edmEntitySet = uriResourceEntitySet.getEntitySet();
	rdfEntityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
	SparqlQueryBuilder sparqlBuilder = new SparqlQueryBuilder(rdfEdmProvider.getRdfModel(),
			rdfEdmProvider.getEdmMetadata(), uriInfo, uriType);

	//prepareQuery
	SparqlStatement sparqlStatement = sparqlBuilder.prepareEntityLinksSparql();
	SparqlEntityCollection rdfResults = sparqlStatement.executeConstruct(rdfEdmProvider, rdfEntityType, null, null);

	if (rdfResults == null) {
		throw new ODataApplicationException("No results", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
				Locale.ENGLISH);
	} else {
		return rdfResults;
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:24,代码来源:SparqlBaseCommand.java

示例3: deleteEntity

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
public static void deleteEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo) throws OData2SparqlException {
	SparqlStatement sparqlStatement = null;
	// 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();
	RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
	// 2. delete the data in backend
	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();

	SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
			rdfEdmProvider);
	try {
		sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteEntity(entityType, keyPredicates);
	} catch (Exception e) {
		log.error(e.getMessage());
		throw new OData2SparqlException(e.getMessage());
	}
	sparqlStatement.executeDelete(rdfEdmProvider);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:22,代码来源:SparqlBaseCommand.java

示例4: updateEntity

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
public static void updateEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity,
		HttpMethod httpMethod) throws OData2SparqlException {
	SparqlStatement sparqlStatement = null;
	// 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();

	RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);

	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations  
	SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
			rdfEdmProvider);
	try {
		sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntity(entityType, keyPredicates,
				requestEntity);
	} catch (Exception e) {
		log.error(e.getMessage());
		throw new OData2SparqlException(e.getMessage());
	}
	sparqlStatement.executeDelete(rdfEdmProvider);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlBaseCommand.java

示例5: updatePrimitiveValue

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
public static void updatePrimitiveValue(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Object entry)
		throws OData2SparqlException {
	SparqlStatement sparqlStatement = null;
	// 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();

	RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);

	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	UriResourcePrimitiveProperty uriResourcePrimitiveProperty = (UriResourcePrimitiveProperty) resourcePaths.get(1);
	EdmProperty edmProperty = uriResourcePrimitiveProperty.getProperty();

	SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
			rdfEdmProvider);
	try {
		sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntitySimplePropertyValue(entityType,
				keyPredicates, edmProperty.getName(), entry);
	} catch (Exception e) {
		log.error(e.getMessage());
		throw new OData2SparqlException(e.getMessage());
	}
	sparqlStatement.executeUpdate(rdfEdmProvider);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:27,代码来源:SparqlBaseCommand.java

示例6: deleteEntityReference

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
public static void deleteEntityReference(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo) throws OData2SparqlException {
	SparqlStatement sparqlStatement = null;
	// 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();

	RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);

	List<UriParameter> entityKeyPredicates = uriResourceEntitySet.getKeyPredicates();
	UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(1);
	RdfAssociation navigationProperty = entityType
			.findNavigationProperty(uriResourceNavigation.getProperty().getName());
	List<UriParameter> navigationKeyPredicates = uriResourceNavigation.getKeyPredicates();
	SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
			rdfEdmProvider);
	try {
		sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteLinkQuery( entityType, entityKeyPredicates,navigationProperty,navigationKeyPredicates);
	} catch (Exception e) {
		log.error(e.getMessage());
		throw new OData2SparqlException(e.getMessage());
	}
	sparqlStatement.executeInsert(rdfEdmProvider);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlBaseCommand.java

示例7: serialize

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
@Override
protected SerializerResult serialize(ODataSerializer serializer,
        InstanceData<EdmPrimitiveType, Property> data, ElasticEdmEntitySet entitySet,
        UriInfo uriInfo) throws SerializerException {
    List<UriResource> resourceParts = uriInfo.getUriResourceParts();
    UriResourceProperty uriProperty = (UriResourceProperty) resourceParts
            .get(resourceParts.size() - 1);
    ElasticEdmProperty edmProperty = (ElasticEdmProperty) uriProperty.getProperty();
    String propertyName = edmProperty.getName();
    return serializer.primitive(serviceMetadata, data.getType(), data.getValue(),
            PrimitiveSerializerOptions.with()
                    .contextURL(createContextUrl(entitySet, true, null, null, propertyName))
                    .scale(edmProperty.getScale()).nullable(edmProperty.isNullable())
                    .precision(edmProperty.getPrecision()).maxLength(edmProperty.getMaxLength())
                    .unicode(edmProperty.isUnicode()).build());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:17,代码来源:PrimitiveProcessorImpl.java

示例8: getProperties

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
/**
 * Get's properties from {@link #groupBy} for aggregation query.
 * 
 * @param groupBy
 *            groupBy instance
 * @return list of properties
 * @throws ODataApplicationException
 *             if any error occurred
 */
private static List<String> getProperties(GroupBy groupBy) throws ODataApplicationException {
    List<String> groupByProperties = new ArrayList<>();
    for (GroupByItem item : groupBy.getGroupByItems()) {
        List<UriResource> path = item.getPath();
        if (path.size() > 1) {
            throwNotImplemented("Grouping by navigation property is not supported yet.");
        }
        UriResource resource = path.get(0);
        if (resource.getKind() == UriResourceKind.primitiveProperty) {
            groupByProperties.add(resource.getSegmentValue());
        } else {
            throwNotImplemented("Grouping by complex type is not supported yet.");
        }
    }
    return groupByProperties;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:26,代码来源:BucketsAggregationsRequestCreator.java

示例9: getSelectList

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
/**
 * Returns the list of fields from URL.
 * @param uriInfo uri info
 * @return fields fields from URL
 */
protected List<String> getSelectList(UriInfo uriInfo) {
    List<String> result = new ArrayList<>();
    SelectOption selectOption = uriInfo.getSelectOption();
    if (selectOption != null) {
        List<SelectItem> selectItems = selectOption.getSelectItems();
        for (SelectItem selectItem : selectItems) {
            List<UriResource> selectParts = selectItem.getResourcePath().getUriResourceParts();
            String fieldName = selectParts.get(selectParts.size() - 1).getSegmentValue();
            result.add(fieldName);
        }
    } else {
        List<UriResource> resourceParts = uriInfo.getUriResourceParts();
        if (resourceParts.size() > 1) {
            UriResource lastResource = resourceParts.get(resourceParts.size() - 1);
            if (lastResource.getKind() == UriResourceKind.primitiveProperty) {
                result.add(((UriResourceProperty) lastResource).getProperty().getName());
            }
        }
    }
    return result;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:27,代码来源:SearchRequestCreator.java

示例10: addSegmentQuery

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
/**
 * Method adds query depending on current and next URI resource segment.
 * 
 * @param segment
 *            current segment
 * @param nextSegment
 *            next segment
 * @return casted queryBuilder
 * @throws ODataApplicationException
 *             if any error occurred
 */
@SuppressWarnings("unchecked")
public T addSegmentQuery(UriResource segment, UriResource nextSegment)
        throws ODataApplicationException {
    ElasticEdmEntityType type = (ElasticEdmEntityType) ((UriResourcePartTyped) segment)
            .getType();
    String esType = type.getESType();
    List<String> ids = collectIds(segment);
    if (nextSegment == null) {
        addIdQuery(esType, ids);
    } else {
        if (nextSegment.getKind() == UriResourceKind.primitiveProperty) {
            addIdQuery(esType, ids);
        } else {
            if (((UriResourceNavigationPropertyImpl) nextSegment).getProperty()
                    .isCollection()) {
                addParentQuery(esType, ids);
            } else {
                addChildQuery(esType, ids);
            }
        }
    }
    return (T) this;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:35,代码来源:ESQueryBuilder.java

示例11: getData

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
/**
 * Helper method for providing some sample data.
 *
 * @param edmEntitySet
 *            for which the data is requested
 * @return data of requested entity set
 */
private EntitySet getData(UriInfo uriInfo) {
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths
			.get(0); // in our example, the first segment is the EntitySet
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();

	EntitySet entitySet = null;

	Map<String, EntityProvider> entityProviders = ctx
			.getBeansOfType(EntityProvider.class);

	for (String entity : entityProviders.keySet()) {
		EntityProvider entityProvider = entityProviders.get(entity);
		if (entityProvider
				.getEntityType().getName()
				
				.equals(edmEntitySet.getEntityType().getName())) {
			entitySet = entityProvider.getEntitySet(uriInfo);
			break;
		}
	}
	return entitySet;
}
 
开发者ID:rohitghatol,项目名称:spring-boot-Olingo-oData,代码行数:31,代码来源:GenericEntityCollectionProcessor.java

示例12: blockTypeFilters

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
private void blockTypeFilters(final UriResource uriResource)
        throws ODataApplicationException
{
    if (((uriResource instanceof UriResourceEntitySet)
            && (((UriResourceEntitySet) uriResource).getTypeFilterOnCollection() != null
            || ((UriResourceEntitySet) uriResource).getTypeFilterOnEntry()
            != null)) || ((uriResource instanceof UriResourceFunction)
            && (((UriResourceFunction) uriResource).getTypeFilterOnCollection() != null
            || ((UriResourceFunction) uriResource).getTypeFilterOnEntry()
            != null)) || ((uriResource instanceof UriResourceNavigation)
            && (((UriResourceNavigation) uriResource).getTypeFilterOnCollection() != null
            || ((UriResourceNavigation) uriResource).getTypeFilterOnEntry() != null)))
    {
        throw new ODataApplicationException("Type filters are not supported.",
                                            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
                                            Locale.ROOT);
    }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:RedHxDiscoveryProcessor.java

示例13: getEdmTypeForContNavProperty

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
private EdmEntityType getEdmTypeForContNavProperty(UriInfo uriInfo) {
  List<UriResource> pathSegments = uriInfo.getUriResourceParts();
  EdmEntityType type = null;
  for(UriResource resource : pathSegments) {
    if (resource instanceof UriResourceNavigation) {
      UriResourceNavigation navResource = (UriResourceNavigation) resource;
      if (navResource.getProperty().containsTarget()) {
        if (navResource.getTypeFilterOnCollection() != null) {
          type = ((EdmEntityType) navResource.getTypeFilterOnCollection());
        } else if (navResource.getTypeFilterOnEntry() != null) {
          type = ((EdmEntityType) navResource.getTypeFilterOnEntry());
        } else {
          type = ((EdmEntityType) navResource.getType());
        }
      }
    }
  }
  return type;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:TechnicalEntityProcessor.java

示例14: readEntity

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的package包/类
/**
 * This method is invoked when a single entity has to be read.
 * In our example, this can be either a "normal" read operation, or a navigation:
 * 
 * Example for "normal" read operation:
 * http://localhost:8080/DemoService/DemoService.svc/Products(1)
 * 
 * Example for navigation
 * http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category
 */
public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
    throws ODataApplicationException, SerializerException {
  
  // The sample service supports only functions imports and entity sets.
  // We do not care about bound functions and composable functions.
  
  UriResource uriResource = uriInfo.getUriResourceParts().get(0); 
  
  if(uriResource instanceof UriResourceEntitySet) {
    readEntityInternal(request, response, uriInfo, responseFormat);
  } else if(uriResource instanceof UriResourceFunction) {
    readFunctionImportInternal(request, response, uriInfo, responseFormat);
  } else {
    throw new ODataApplicationException("Only EntitySet is supported",
        HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
  }
  
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:DemoEntityProcessor.java

示例15: updateEntity

import org.apache.olingo.server.api.uri.UriResource; //导入依赖的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


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