本文整理汇总了Java中org.apache.olingo.commons.api.ex.ODataException类的典型用法代码示例。如果您正苦于以下问题:Java ODataException类的具体用法?Java ODataException怎么用?Java ODataException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataException类属于org.apache.olingo.commons.api.ex包,在下文中一共展示了ODataException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntityType
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public CsdlEntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException {
String nameSpace = edmFQName.getNamespace();
try {
for (CsdlSchema schema : this.rdfEdmModelProvider.getEdmMetadata().getSchemas()) {
if (nameSpace.equals(schema.getNamespace())) {
String entityTypeName = edmFQName.getName();
for (CsdlEntityType entityType : schema.getEntityTypes()) {
if (entityTypeName.equals(entityType.getName())) {
return entityType;
}
}
}
}
} catch (NullPointerException e) {
log.error("NullPointerException getEntityType " + edmFQName);
throw new ODataException("NullPointerException getEntityType " + edmFQName);
}
return null;
}
示例2: getComplexType
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public CsdlComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
String nameSpace = edmFQName.getNamespace();
try {
for (CsdlSchema schema : this.rdfEdmModelProvider.getEdmMetadata().getSchemas()) {
if (nameSpace.equals(schema.getNamespace())) {
String complexTypeName = edmFQName.getName();
for (CsdlComplexType complexType : schema.getComplexTypes()) {
if (complexTypeName.equals(complexType.getName())) {
return complexType;
}
}
}
}
} catch (NullPointerException e) {
log.error("NullPointerException getComplexType " + edmFQName);
throw new ODataException("NullPointerException getComplexType " + edmFQName);
}
return null;
}
示例3: getEntitySet
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer, final String name) throws ODataException {
try {
//for (CsdlSchema schema : this.rdfEdmModelProvider.getEdmMetadata().getSchemas()) {
CsdlEntityContainer schemaEntityContainer = this.rdfEdmModelProvider.getEdmMetadata().getSchema(entityContainer.getNamespace()).getEntityContainer();
//if (entityContainer.equals(schemaEntityContainer.getName())) {
for (CsdlEntitySet entitySet : schemaEntityContainer.getEntitySets()) {
if (name.equals(entitySet.getName())) {
return entitySet;
}
}
//}
// }
} catch (NullPointerException e) {
log.error("NullPointerException getEntitySet " + entityContainer + " " + name);
throw new ODataException("NullPointerException getEntitySet " + entityContainer + " " + name);
}
return null;
}
示例4: getFunctionImport
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public CsdlFunctionImport getFunctionImport(FullQualifiedName entityContainer, final String name)
throws ODataException {
try {
//for (CsdlSchema schema : this.rdfEdmModelProvider.getEdmMetadata().getSchemas()) {
CsdlEntityContainer schemaEntityContainer = this.rdfEdmModelProvider.getEdmMetadata().getSchema(entityContainer.getNamespace()).getEntityContainer();
//if (entityContainer.equals(schemaEntityContainer.getName())) {
for (CsdlFunctionImport functionImport : schemaEntityContainer.getFunctionImports()) {
if (name.equals(functionImport.getName())) {
return functionImport;
}
}
//}
//}
} catch (NullPointerException e) {
log.error("NullPointerException getFunctionImport " + entityContainer + " " + name);
throw new ODataException("NullPointerException getFunctionImport " + entityContainer + " " + name);
}
return null;
}
示例5: getEntityContainerInfo
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public CsdlEntityContainerInfo getEntityContainerInfo(FullQualifiedName entityContainer) throws ODataException {
if (entityContainer == null) {
// Assume request for null container means default container
return new CsdlEntityContainerInfo().setContainerName(new FullQualifiedName(RdfConstants.ENTITYCONTAINERNAMESPACE,RdfConstants.ENTITYCONTAINER));
} else {
try {
for (CsdlSchema schema : this.rdfEdmModelProvider.getEdmMetadata().getSchemas()) {
CsdlEntityContainer schemaEntityContainer = schema.getEntityContainer();
if (entityContainer.equals(schemaEntityContainer.getName())) {
return new CsdlEntityContainerInfo().setContainerName(entityContainer);
}
}
} catch (NullPointerException e) {
log.error("NullPointerException getEntityContainerInfo " + entityContainer);
throw new ODataException("NullPointerException getEntityContainerInfo " + entityContainer);
}
}
return null;
}
示例6: getEntityType
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public ElasticCsdlEntityType getEntityType(FullQualifiedName entityTypeName)
throws ODataException {
String esIndex = namespaceToIndex(entityTypeName.getNamespace());
// If there is no index mapping for provided namespace - return null, no
// entity type is found.
if (esIndex != null) {
List<ElasticCsdlEntityType> entityTypes = getEntityTypes(esIndex);
for (ElasticCsdlEntityType entityType : entityTypes) {
if (entityType.getESType().equals(entityTypeName.getName())) {
return entityType;
}
}
}
return null;
}
示例7: getEntityContainer
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public CsdlEntityContainer getEntityContainer() throws ODataException {
// create EntityContainer
CsdlEntityContainer entityContainer = new CsdlEntityContainer();
entityContainer.setName(getContainerName().getName());
List<CsdlSchema> schemas = getSchemas();
for (CsdlSchema schema : schemas) {
for (CsdlEntitySet entitySet : schema.getEntityContainer().getEntitySets()) {
if (entitySet.isIncludeInServiceDocument()) {
entityContainer.getEntitySets().add(entitySet);
}
}
}
return entityContainer;
}
示例8: getComplexTypes
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
/**
* Get's complex types for specific Elasticsearch index.
*
* @param index
* index name
* @return list of complex types
* @throws ODataException
* if any error occurred
*/
public List<ElasticCsdlComplexType> getComplexTypes(String index) throws ODataException {
Map<ElasticCsdlComplexType, Set<CsdlProperty>> complexMappings = new HashMap<>();
for (ObjectCursor<String> key : mappingMetaDataProvider.getAllMappings(index).keys()) {
String type = key.value;
ParsedMapWrapper typeProperties = getTypeProperties(index, type);
for (String field : typeProperties.getMap().keySet()) {
ParsedMapWrapper fieldMap = typeProperties.mapValue(field);
if (isNested(fieldMap.stringValue(FIELD_DATATYPE_PROPERTY))) {
ParsedMapWrapper properties = fieldMap.mapValue(PROPERTIES_PROPERTY);
createComplexTypes(index, type, field, properties).entrySet().stream()
.forEach(e -> getAndPut(complexMappings, e.getKey(), e.getValue()));
}
}
}
List<ElasticCsdlComplexType> complexTypes = new ArrayList<>();
for (Entry<ElasticCsdlComplexType, Set<CsdlProperty>> entry : complexMappings.entrySet()) {
ElasticCsdlComplexType complexType = entry.getKey();
complexType.setProperties(new ArrayList<>(entry.getValue()));
complexTypes.add(complexType);
}
return complexTypes;
}
示例9: getProperties_TypeNameAndCorrectMetaData_ListOfCsdlPropertiesRetrieved
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Test
public void getProperties_TypeNameAndCorrectMetaData_ListOfCsdlPropertiesRetrieved()
throws IOException, ODataException {
MultyElasticIndexCsdlEdmProvider edmProvider = new MultyElasticIndexCsdlEdmProvider(
metaDataProvider, indices, nestedTypeMapper);
List<CsdlProperty> csdlProperties = edmProvider.getProperties(AUTHORS_INDEX, AUTHOR_TYPE,
getStubProperties());
assertEquals(2, csdlProperties.size());
for (CsdlProperty property : csdlProperties) {
assertTrue(property instanceof ElasticCsdlProperty);
assertEquals(AUTHORS_INDEX, ((ElasticCsdlProperty) property).getESIndex());
assertEquals(AUTHOR_TYPE, ((ElasticCsdlProperty) property).getESType());
assertEquals(property.getName(), ((ElasticCsdlProperty) property).getESField());
assertNotNull(property.getTypeAsFQNObject());
}
}
示例10: createEntityType_IndexAndTypeWithCustomIdProperty_EntityTypeRetrived
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Test
public void createEntityType_IndexAndTypeWithCustomIdProperty_EntityTypeRetrived()
throws ODataException, IOException {
MultyElasticIndexCsdlEdmProvider edmProvider = spy(
new MultyElasticIndexCsdlEdmProvider(metaDataProvider, indices));
MappingMetaData metaData = mock(MappingMetaData.class);
when(metaDataProvider.getMappingForType(AUTHORS_INDEX, AUTHOR_TYPE)).thenReturn(metaData);
doReturn(new ArrayList<>()).when(edmProvider).getProperties(AUTHORS_INDEX, AUTHOR_TYPE,
metaData);
doReturn(new ArrayList<>()).when(edmProvider).getNavigationProperties(AUTHORS_INDEX,
AUTHOR_TYPE);
ElasticCsdlEntityType entityType = edmProvider.createEntityType(AUTHORS_INDEX, AUTHOR_TYPE);
assertTrue(entityType instanceof ElasticCsdlEntityType);
assertEquals(AUTHORS_INDEX, ((ElasticCsdlEntityType) entityType).getESIndex());
assertEquals(AUTHOR_TYPE, ((ElasticCsdlEntityType) entityType).getESType());
List<CsdlProperty> properties = entityType.getProperties();
assertEquals(1, properties.size());
CsdlProperty idProperty = properties.get(0);
assertEquals(ElasticConstants.ID_FIELD_NAME, idProperty.getName());
List<CsdlPropertyRef> keys = entityType.getKey();
assertEquals(1, keys.size());
CsdlPropertyRef idRef = keys.get(0);
assertEquals(ElasticConstants.ID_FIELD_NAME, idRef.getName());
}
示例11: getEnityTypes_IndexWithMappings_ListEntityTypesRetrieved
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Test
public void getEnityTypes_IndexWithMappings_ListEntityTypesRetrieved()
throws ODataException, IOException {
MultyElasticIndexCsdlEdmProvider edmProvider = spy(
new MultyElasticIndexCsdlEdmProvider(metaDataProvider, indices));
Builder<String, MappingMetaData> mappingsBuilder = ImmutableOpenMap.builder();
mappingsBuilder.put(BOOK_TYPE, null);
when(metaDataProvider.getAllMappings(AUTHORS_INDEX)).thenReturn(mappingsBuilder.build());
doAnswer(answer -> new ElasticCsdlEntityType().setESIndex(answer.getArgument(0))
.setName(answer.getArgument(1))).when(edmProvider).createEntityType(AUTHORS_INDEX,
BOOK_TYPE);
List<ElasticCsdlEntityType> enityTypes = edmProvider.getEntityTypes(AUTHORS_INDEX);
assertEquals(1, enityTypes.size());
ElasticCsdlEntityType entityType = enityTypes.get(0);
assertEquals(AUTHORS_INDEX, entityType.getESIndex());
assertEquals(BOOK_TYPE, entityType.getESType());
assertEquals(BOOK_TYPE, entityType.getName());
}
示例12: getEntityContainerForSchema_Namespace_EntityContainerWithEntitySetsRetrieved
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Test
public void getEntityContainerForSchema_Namespace_EntityContainerWithEntitySetsRetrieved()
throws ODataException {
MultyElasticIndexCsdlEdmProvider edmProvider = spy(
new MultyElasticIndexCsdlEdmProvider(metaDataProvider, indices));
Builder<String, MappingMetaData> mappingsBuilder = ImmutableOpenMap.builder();
mappingsBuilder.put(AUTHOR_TYPE, null);
mappingsBuilder.put(BOOK_TYPE, null);
when(metaDataProvider.getAllMappings(AUTHORS_INDEX)).thenReturn(mappingsBuilder.build());
doReturn(new ArrayList<>()).when(edmProvider).getNavigationProperties(AUTHORS_INDEX,
AUTHOR_TYPE);
doReturn(new ArrayList<>()).when(edmProvider).getNavigationProperties(AUTHORS_INDEX,
BOOK_TYPE);
CsdlEntityContainer entityContainer = edmProvider
.getEntityContainerForSchema(AUTHORS_INDEX);
assertEquals(edmProvider.getContainerName().getName(), entityContainer.getName());
assertEquals(2, entityContainer.getEntitySets().size());
}
示例13: getEntityContainer_ContainerWithEntitySetsRetrieved
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Test
public void getEntityContainer_ContainerWithEntitySetsRetrieved() throws ODataException {
MultyElasticIndexCsdlEdmProvider edmProvider = spy(
new MultyElasticIndexCsdlEdmProvider(metaDataProvider, indices));
List<CsdlSchema> schemas = new ArrayList<>();
CsdlSchema schema1 = mock(CsdlSchema.class);
CsdlEntityContainer container = mock(CsdlEntityContainer.class);
List<CsdlEntitySet> entitySets = new ArrayList<>();
CsdlEntitySet set1 = mock(CsdlEntitySet.class);
when(set1.isIncludeInServiceDocument()).thenReturn(true);
entitySets.add(set1);
entitySets.add(mock(CsdlEntitySet.class));
when(container.getEntitySets()).thenReturn(entitySets);
when(schema1.getEntityContainer()).thenReturn(container);
schemas.add(schema1);
CsdlSchema schema2 = mock(CsdlSchema.class);
when(schema2.getEntityContainer()).thenReturn(mock(CsdlEntityContainer.class));
schemas.add(schema2);
doReturn(schemas).when(edmProvider).getSchemas();
CsdlEntityContainer entityContainer = edmProvider.getEntityContainer();
assertEquals(edmProvider.getContainerName().getName(), entityContainer.getName());
assertEquals(1, entityContainer.getEntitySets().size());
}
示例14: getComplexType_DifferenetNames_ExpectedValuesRetrieved
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Test
public void getComplexType_DifferenetNames_ExpectedValuesRetrieved() throws ODataException {
MultyElasticIndexCsdlEdmProvider edmProvider = spy(
new MultyElasticIndexCsdlEdmProvider(metaDataProvider, indices));
List<CsdlSchema> schemas = new ArrayList<>();
CsdlSchema schema = mock(CsdlSchema.class);
String namespace = "OData";
when(schema.getNamespace()).thenReturn(namespace);
ElasticCsdlComplexType expectedComplexType = mock(ElasticCsdlComplexType.class);
String complexTypeName = "dimension";
when(schema.getComplexType(complexTypeName)).thenReturn(expectedComplexType);
schemas.add(schema);
doReturn(schemas).when(edmProvider).getSchemas();
ElasticCsdlComplexType actualComplexType = edmProvider
.getComplexType(new FullQualifiedName(namespace, complexTypeName));
assertEquals(expectedComplexType, actualComplexType);
assertNull(edmProvider.getComplexType(new FullQualifiedName("Test", "complex")));
}
示例15: getActions
import org.apache.olingo.commons.api.ex.ODataException; //导入依赖的package包/类
@Override
public List<CsdlAction> getActions(FullQualifiedName actionName) throws ODataException {
List<CsdlAction> list = null;
/**
* todo change this lookup to a map.get();
*/
for (RedHxEdmActionProvider edmProvider : EDM_ACTION_PROVIDER_LIST) {
list = edmProvider.getActionList(actionName);
if (!list.isEmpty()) {
break;
}
}
if (list == null) {
list = EMPTY_ACTION_LIST;
}
return list;
}