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


Java UriResourceEntitySet类代码示例

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


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

示例1: readReferenceCollection

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

示例2: deleteEntity

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

示例3: updateEntity

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

示例4: updatePrimitiveValue

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

示例5: deleteEntityReference

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

示例6: clausesPath_URI1

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
private StringBuilder clausesPath_URI1(String indent) throws EdmException {
	StringBuilder clausesPath = new StringBuilder();
	if (uriInfo.getUriResourceParts().size() > 1) {
		clausesPath.append(clausesPathNavigation(indent, uriInfo.getUriResourceParts(),
				((UriResourceEntitySet) uriInfo.getUriResourceParts().get(0)).getKeyPredicates()));
	} else {
		clausesPath.append(indent).append("?" + rdfEntityType.entityTypeName
				+ "_s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?class .\n");
		// clausesPath.append(indent).append(
		// "?class (<http://www.w3.org/2000/01/rdf-schema#subClassOf>)* <" +
		// rdfEntityType.getIRI() + "> .\n");

		clausesPath.append(indent).append(valuesSubClassOf(rdfEntityType)).append("}\n");
	}
	return clausesPath;
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlQueryBuilder.java

示例7: clausesPath_URI15

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
private StringBuilder clausesPath_URI15(String indent) throws EdmException, OData2SparqlException {
	StringBuilder clausesPath = new StringBuilder();
	if (uriInfo.getUriResourceParts().size() > 2) {
		clausesPath.append(clausesPathNavigation(indent, uriInfo.getUriResourceParts(),
				((UriResourceEntitySet) uriInfo.getUriResourceParts().get(0)).getKeyPredicates()));
	} else {
		if (rdfTargetEntityType.isOperation()) {
			clausesPath.append(indent).append(preprocessOperationQuery(rdfTargetEntityType));
		} else {
			clausesPath.append(indent).append("?" + rdfEntityType.entityTypeName
					+ "_s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?class .\n");
			// clausesPath.append(indent).append(
			// "?class (<http://www.w3.org/2000/01/rdf-schema#subClassOf>)*
			// <"
			// + rdfEntityType.getIRI() + "> .\n");
			clausesPath.append(indent).append(valuesSubClassOf(rdfEntityType)).append("}\n");
		}
	}
	return clausesPath;
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:21,代码来源:SparqlQueryBuilder.java

示例8: getData

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

示例9: visit

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
@Override
public void visit(UriResourceEntitySet info) {
	this.edmEntitySet = info.getEntitySet();
	this.edmEntityTable = findTable(edmEntitySet, this.metadata);
	this.edmEntityTableGroup = new GroupSymbol("g0", this.edmEntityTable.getFullName()); //$NON-NLS-1$
	this.fromClause = new UnaryFromClause(this.edmEntityTableGroup);

	// URL is like /entitySet(key)s
	if (info.getKeyPredicates() != null && !info.getKeyPredicates().isEmpty()) {
		List<UriParameter> keys = info.getKeyPredicates();
		try {
			this.criteria = buildEntityKeyCriteria(this.edmEntityTable, this.edmEntityTableGroup, keys);
		} catch (TeiidException e) {
			this.exceptions.add(e);
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:18,代码来源:ODataSQLBuilder.java

示例10: getEntityByReference

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
protected Entity getEntityByReference(final String entityId, final String rawServiceRoot)
    throws DataProviderException {
  try {
    final UriResourceEntitySet uriResource =
        odata.createUriHelper().parseEntityId(edm, entityId, rawServiceRoot);
    final Entity targetEntity = read(uriResource.getEntitySet(), uriResource.getKeyPredicates());

    if (targetEntity != null) {
      return targetEntity;
    } else {
      throw new DataProviderException("Entity not found", HttpStatusCode.NOT_FOUND);
    }
  } catch (DeserializerException e) {
    throw new DataProviderException("Invalid entity-id", HttpStatusCode.BAD_REQUEST);
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:17,代码来源:DataProvider.java

示例11: blockTypeFilters

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

示例12: getEntitySetBasedOnTypeCast

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
protected EdmEntitySet getEntitySetBasedOnTypeCast(UriResourceEntitySet uriResource) {
  EdmEntitySet entitySet = null;
  EdmEntityContainer container = this.serviceMetadata.getEdm().getEntityContainer();
  if (uriResource.getTypeFilterOnEntry() != null ||
      uriResource.getTypeFilterOnCollection() != null) {
    List<EdmEntitySet> entitySets = container.getEntitySets();
    for (EdmEntitySet entitySet1 : entitySets) {
      EdmEntityType entityType = entitySet1.getEntityType();
      if ((uriResource.getTypeFilterOnEntry() != null && 
          entityType.getName().equalsIgnoreCase(uriResource.getTypeFilterOnEntry().getName())) ||
          (uriResource.getTypeFilterOnCollection() != null && 
          entityType.getName().equalsIgnoreCase(uriResource.getTypeFilterOnCollection().getName()))) {
        entitySet = entitySet1;
        break;
      }
    }
  } else {
    entitySet = uriResource.getEntitySet();
  }
  return entitySet;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:TechnicalProcessor.java

示例13: mustValidate

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
private boolean mustValidate(final String uri, final String entitySetName)
    throws UriParserException, UriValidationException, PreconditionException {
  final UriInfo uriInfo = new Parser(edm, odata).parseUri(uri, null, null, null);
  final List<UriResource> parts = uriInfo.getUriResourceParts();
  final boolean isMedia = parts.size() >= 2
      && parts.get(parts.size() - 1) instanceof UriResourceValue
      && parts.get(parts.size() - 2) instanceof UriResourceEntitySet;

  CustomETagSupport support = mock(CustomETagSupport.class);
  final Answer<Boolean> answer = new Answer<Boolean>() {
    public Boolean answer(final InvocationOnMock invocation) throws Throwable {
      if (entitySetName != null) {
        assertEquals(entitySetName, ((EdmBindingTarget) invocation.getArguments()[0]).getName());
      }
      return true;
    }};
  when(support.hasETag(any(EdmBindingTarget.class))).thenAnswer(answer);
  when(support.hasMediaETag(any(EdmBindingTarget.class))).thenAnswer(answer);

  return new PreconditionsValidator(uriInfo).mustValidatePreconditions(support, isMedia);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:PreconditionsValidatorTest.java

示例14: handleCountDispatching

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
private void handleCountDispatching(final ODataRequest request, final ODataResponse response,
    final int lastPathSegmentIndex) throws ODataApplicationException, ODataLibraryException {
  final UriResource resource = uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1);
  if (resource instanceof UriResourceEntitySet
      || resource instanceof UriResourceNavigation
      || resource instanceof UriResourceFunction
          && ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.ENTITY) {
    handler.selectProcessor(CountEntityCollectionProcessor.class)
        .countEntityCollection(request, response, uriInfo);
  } else if (resource instanceof UriResourcePrimitiveProperty
      || resource instanceof UriResourceFunction
          && ((UriResourceFunction) resource).getType().getKind() == EdmTypeKind.PRIMITIVE) {
    handler.selectProcessor(CountPrimitiveCollectionProcessor.class)
        .countPrimitiveCollection(request, response, uriInfo);
  } else {
    handler.selectProcessor(CountComplexCollectionProcessor.class)
        .countComplexCollection(request, response, uriInfo);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ODataDispatcher.java

示例15: requireMediaResourceInCaseOfEntity

import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入依赖的package包/类
private void requireMediaResourceInCaseOfEntity(UriResource resource) throws UriParserSemanticException {
  // If the resource is an entity or navigatio
  if (resource instanceof UriResourceEntitySet && !((UriResourceEntitySet) resource).getEntityType().hasStream()
      || resource instanceof UriResourceNavigation
      && !((EdmEntityType) ((UriResourceNavigation) resource).getType()).hasStream()) {
    throw new UriParserSemanticException("$value on entity is only allowed on media resources.",
        UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue());
  }

  // Functions can also deliver an entity. In this case we have to check if the returned entity is a media resource
  if (resource instanceof UriResourceFunction) {
    EdmType returnType = ((UriResourceFunction) resource).getFunction().getReturnType().getType();
    //Collection check is above so not needed here
    if (returnType instanceof EdmEntityType && !((EdmEntityType) returnType).hasStream()) {
      throw new UriParserSemanticException("$value on returned entity is only allowed on media resources.",
          UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue());
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ResourcePathParser.java


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