本文整理汇总了Java中org.apache.olingo.commons.api.edm.Edm.getTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java Edm.getTypeDefinition方法的具体用法?Java Edm.getTypeDefinition怎么用?Java Edm.getTypeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.edm.Edm
的用法示例。
在下文中一共展示了Edm.getTypeDefinition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nothingSpecifiedMustNotResultInExceptions
import org.apache.olingo.commons.api.edm.Edm; //导入方法依赖的package包/类
@Test
public void nothingSpecifiedMustNotResultInExceptions() throws Exception {
CsdlEdmProvider localProvider = mock(CsdlEdmProvider.class);
when(localProvider.getActions(FQN)).thenReturn(null);
when(localProvider.getFunctions(FQN)).thenReturn(null);
Edm localEdm = new EdmProviderImpl(localProvider);
localEdm.getUnboundAction(FQN);
localEdm.getUnboundFunction(FQN, null);
localEdm.getBoundAction(FQN, FQN, true);
localEdm.getBoundFunction(FQN, FQN, true, null);
localEdm.getComplexType(FQN);
localEdm.getEntityContainer(FQN);
localEdm.getEntityType(FQN);
localEdm.getEnumType(FQN);
localEdm.getTypeDefinition(FQN);
}
示例2: EdmTypeInfo
import org.apache.olingo.commons.api.edm.Edm; //导入方法依赖的package包/类
private EdmTypeInfo(final Edm edm, final String typeExpression) {
String baseType;
final int collStartIdx = typeExpression.indexOf("Collection(");
final int collEndIdx = typeExpression.lastIndexOf(')');
if (collStartIdx == -1) {
baseType = typeExpression;
collection = false;
} else {
if (collEndIdx == -1) {
throw new IllegalArgumentException("Malformed type: " + typeExpression);
}
collection = true;
baseType = typeExpression.substring(collStartIdx + 11, collEndIdx);
}
if (baseType.startsWith("#")) {
baseType = baseType.substring(1);
}
String typeName;
String namespace;
final int lastDotIdx = baseType.lastIndexOf('.');
if (lastDotIdx == -1) {
namespace = EdmPrimitiveType.EDM_NAMESPACE;
typeName = baseType;
} else {
namespace = baseType.substring(0, lastDotIdx);
typeName = baseType.substring(lastDotIdx + 1);
}
if (typeName == null || typeName.isEmpty()) {
throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
}
fullQualifiedName = new FullQualifiedName(namespace, typeName);
try {
primitiveType = EdmPrimitiveTypeKind.valueOf(typeName);
} catch (final IllegalArgumentException e) {
primitiveType = null;
}
if (primitiveType == null && edm != null) {
typeDefinition = edm.getTypeDefinition(fullQualifiedName);
if (typeDefinition == null) {
enumType = edm.getEnumType(fullQualifiedName);
if (enumType == null) {
complexType = edm.getComplexType(fullQualifiedName);
if (complexType == null) {
entityType = edm.getEntityType(fullQualifiedName);
}
}
}
}
}
示例3: fromdoc1
import org.apache.olingo.commons.api.edm.Edm; //导入方法依赖的package包/类
/**
* Tests Example 85 from CSDL specification.
*/
@Test
public void fromdoc1() {
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).
toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
assertNotNull(metadata);
assertFalse(metadata.getReferences().isEmpty());
assertEquals("Org.OData.Measures.V1", metadata.getReferences().get(1).getIncludes().get(0).getNamespace());
final CsdlEntityType product = metadata.getSchema(0).getEntityType("Product");
assertTrue(product.hasStream());
assertEquals("UoM.ISOCurrency", product.getProperty("Price").getAnnotations().get(0).getTerm());
assertEquals("Products", product.getNavigationProperty("Supplier").getPartner());
final CsdlEntityType category = metadata.getSchema(0).getEntityType("Category");
assertNotNull(category);
final CsdlComplexType address = metadata.getSchema(0).getComplexType("Address");
assertFalse(address.getNavigationProperty("Country").getReferentialConstraints().isEmpty());
assertEquals("Name",
address.getNavigationProperty("Country").getReferentialConstraints().get(0).getReferencedProperty());
final CsdlFunction productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0);
assertNotNull(productsByRating.getParameter("Rating"));
assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType());
assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType());
assertTrue(productsByRating.getReturnType().isCollection());
final CsdlSingleton contoso = metadata.getSchema(0).getEntityContainer().getSingleton("Contoso");
assertNotNull(contoso);
assertFalse(contoso.getNavigationPropertyBindings().isEmpty());
assertEquals("Products", contoso.getNavigationPropertyBindings().get(0).getPath());
final CsdlFunctionImport functionImport = metadata.getSchema(0).getEntityContainer().
getFunctionImport("ProductsByRating");
assertNotNull(functionImport);
assertEquals(metadata.getSchema(0).getNamespace() + "." + productsByRating.getName(),
functionImport.getFunction());
// Now let's go high-level
final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
assertNotNull(edm);
List<EdmSchema> schemaList = edm.getSchemas();
assertNotNull(schemaList);
assertEquals(1, schemaList.size());
EdmSchema schema = schemaList.get(0);
EdmEntityContainer demoService = schema.getEntityContainer();
assertNotNull(demoService);
EdmFunction function = schema.getFunctions().get(0);
final EdmFunctionImport fi = demoService.getFunctionImport(function.getName());
assertNotNull(fi);
assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
final EdmFunction edmFunction =
edm.getUnboundFunction(
new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), function
.getParameterNames());
assertNotNull(edmFunction);
assertEquals(edmFunction.getName(), fi.getUnboundFunction(function.getParameterNames()).getName());
assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(function.getParameterNames()).getNamespace());
assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(function.getParameterNames())
.getParameterNames());
assertEquals(edmFunction.getReturnType().getType().getName(),
fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getName());
assertEquals(edmFunction.getReturnType().getType().getNamespace(),
fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getNamespace());
final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight"));
assertNotNull(weight);
assertEquals(EdmInt32.getInstance(), weight.getUnderlyingType());
assertFalse(weight.getAnnotations().isEmpty());
assertEquals("Kilograms", weight.getAnnotations().get(0).getExpression().asConstant().getValueAsString());
}