本文整理汇总了Java中org.apache.olingo.odata2.api.edm.provider.Schema类的典型用法代码示例。如果您正苦于以下问题:Java Schema类的具体用法?Java Schema怎么用?Java Schema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Schema类属于org.apache.olingo.odata2.api.edm.provider包,在下文中一共展示了Schema类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: extendJPAEdmSchema
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
public void extendJPAEdmSchema(JPAEdmSchemaView view) {
ResourceBundle i18n = ODataContextUtil.getResourceBundle("i18n");
final Schema edmSchema = view.getEdmSchema();
for (EntityType entityType : edmSchema.getEntityTypes()) {
for (Property property : entityType.getProperties()) {
String label = null;
if (i18n != null) { try { label = i18n.getString(entityType.getName() + "." + property.getName()); } catch (Exception e) {} }
List<AnnotationAttribute> annotationAttributeList = new ArrayList<AnnotationAttribute>();
if (label != null) {
annotationAttributeList.add(new AnnotationAttribute()
.setNamespace(SAP_NAMESPACE)
.setPrefix(SAP_PREFIX)
.setName(LABEL).setText(label));
}
annotationAttributeList.addAll(getSapPropertyAnnotations(entityType, property));
property.setAnnotationAttributes(annotationAttributeList);
}
}
addSmartAnnotations(edmSchema);
}
开发者ID:jpenninkhof,项目名称:odata-boilerplate,代码行数:24,代码来源:JPAEdmExtension.java
示例2: loadAnnotatedClassesFromPackage
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void loadAnnotatedClassesFromPackage() throws Exception {
AnnotationEdmProvider localAep = new AnnotationEdmProvider(TEST_MODEL_PACKAGE);
// validate employee
EntityType employee = localAep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Employee"));
assertEquals("Employee", employee.getName());
final List<PropertyRef> employeeKeys = employee.getKey().getKeys();
assertEquals(1, employeeKeys.size());
assertEquals("EmployeeId", employeeKeys.get(0).getName());
assertEquals(6, employee.getProperties().size());
assertEquals(3, employee.getNavigationProperties().size());
List<Schema> schemas = localAep.getSchemas();
assertEquals(1, schemas.size());
EntityContainerInfo info = localAep.getEntityContainerInfo(ModelSharedConstants.CONTAINER_1);
assertTrue(info.isDefaultEntityContainer());
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:AnnotationEdmProviderTest.java
示例3: schemaBasic
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void schemaBasic() throws Exception {
assertNotNull(aep);
List<Schema> schemas = aep.getSchemas();
assertEquals(1, schemas.size());
Schema schema = schemas.get(0);
List<EntityContainer> containers = schema.getEntityContainers();
assertEquals(1, containers.size());
EntityContainer container = containers.get(0);
assertEquals(ModelSharedConstants.CONTAINER_1, container.getName());
final List<EntitySet> entitySets = container.getEntitySets();
assertEquals(6, entitySets.size());
List<Association> associations = schema.getAssociations();
assertEquals(5, associations.size());
for (Association association : associations) {
assertNotNull(association.getName());
validateAssociation(association);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:AnnotationEdmProviderTest.java
示例4: getAssociation
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException {
if (edmFQName != null) {
if (associations.containsKey(edmFQName.toString())) {
return associations.get(edmFQName.toString());
} else if (schemas == null) {
getSchemas();
}
for (Schema schema : schemas) {
if (schema.getNamespace().equals(edmFQName.getNamespace())) {
if (schema.getAssociations() == null) {
return null;
}
for (Association association : schema.getAssociations()) {
if (association.getName().equals(edmFQName.getName())) {
associations.put(edmFQName.toString(), association);
return association;
}
}
}
}
}
return null;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:ODataJPAEdmProvider.java
示例5: getEntitySetInfos
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
public List<EdmEntitySetInfo> getEntitySetInfos() throws ODataException {
if (entitySetInfos == null) {
entitySetInfos = new ArrayList<EdmEntitySetInfo>();
if (schemas == null) {
schemas = edmProvider.getSchemas();
}
for (Schema schema : schemas) {
for (EntityContainer entityContainer : listOrEmptyList(schema.getEntityContainers())) {
for (EntitySet entitySet : listOrEmptyList(entityContainer.getEntitySets())) {
EdmEntitySetInfo entitySetInfo = new EdmEntitySetInfoImplProv(entitySet, entityContainer);
entitySetInfos.add(entitySetInfo);
}
}
}
}
return entitySetInfos;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:EdmServiceMetadataImplProv.java
示例6: getAssociationSet
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association,
final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException {
for (Schema schema : dataServices.getSchemas()) {
for (EntityContainer container : schema.getEntityContainers()) {
if (container.getName().equals(entityContainer)) {
for (AssociationSet associationSet : container.getAssociationSets()) {
if (associationSet.getAssociation().equals(association)
&& ((associationSet.getEnd1().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd1()
.getRole().equals(sourceEntitySetRole))
|| (associationSet.getEnd2().getEntitySet().equals(sourceEntitySetName) && associationSet.getEnd2()
.getRole().equals(sourceEntitySetRole)))) {
return associationSet;
}
}
}
}
}
return null;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:EdmxProvider.java
示例7: createEntitySets
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
protected List<EdmEntitySet> createEntitySets() throws ODataException {
List<EdmEntitySet> edmEntitySets = new ArrayList<EdmEntitySet>();
if (schemas == null) {
schemas = edmProvider.getSchemas();
}
for (Schema schema : schemas) {
for (EntityContainer entityContainer : schema.getEntityContainers()) {
for (EntitySet entitySet : entityContainer.getEntitySets()) {
EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName());
edmEntitySets.add(new EdmEntitySetImplProv(this, entitySet, edmEntityContainer));
}
}
}
return edmEntitySets;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:EdmImplProv.java
示例8: createFunctionImports
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
protected List<EdmFunctionImport> createFunctionImports() throws ODataException {
List<EdmFunctionImport> edmFunctionImports = new ArrayList<EdmFunctionImport>();
if (schemas == null) {
schemas = edmProvider.getSchemas();
}
for (Schema schema : schemas) {
for (EntityContainer entityContainer : schema.getEntityContainers()) {
for (FunctionImport functionImport : entityContainer.getFunctionImports()) {
EdmEntityContainer edmEntityContainer = createEntityContainer(entityContainer.getName());
edmFunctionImports.add(new EdmFunctionImportImplProv(this, functionImport, edmEntityContainer));
}
}
}
return edmFunctionImports;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:EdmImplProv.java
示例9: writeInvalidMetadata
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test(expected = Exception.class)
public void writeInvalidMetadata() throws Exception {
disableLogging(this.getClass());
List<Schema> schemas = new ArrayList<Schema>();
List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
annotationElements.add(new AnnotationElement().setText("hallo"));
Schema schema = new Schema().setAnnotationElements(annotationElements);
schema.setNamespace("http://namespace.com");
schemas.add(schema);
DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
OutputStreamWriter writer = null;
CircleStreamBuffer csb = new CircleStreamBuffer();
writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:XmlMetadataProducerTest.java
示例10: before
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Before
public void before() throws ODataException {
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put("atom", Edm.NAMESPACE_ATOM_2005);
prefixMap.put("a", Edm.NAMESPACE_APP_2007);
prefixMap.put("xml", Edm.NAMESPACE_XML_1998);
prefixMap.put("custom", "http://localhost");
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
schemas = new ArrayList<Schema>();
EdmProvider edmProvider = mock(EdmProvider.class);
when(edmProvider.getSchemas()).thenReturn(schemas);
EdmServiceMetadata edmServiceMetadata = new EdmServiceMetadataImplProv(edmProvider);
edm = mock(Edm.class);
when(edm.getServiceMetadata()).thenReturn(edmServiceMetadata);
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:AtomServiceDocumentProducerTest.java
示例11: writeServiceDocumentWithOneEnitySetOneContainerOneSchema
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void writeServiceDocumentWithOneEnitySetOneContainerOneSchema() throws Exception {
List<EntitySet> entitySets = new ArrayList<EntitySet>();
entitySets.add(new EntitySet().setName("Employees"));
List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
entityContainers.add(new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(
entitySets));
schemas.add(new Schema().setEntityContainers(entityContainers));
ODataResponse response = new AtomEntityProvider().writeServiceDocument(edm, "http://localhost");
String xmlString = verifyResponse(response);
assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString);
assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString);
assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString);
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:18,代码来源:AtomServiceDocumentProducerTest.java
示例12: writeServiceDocumentWithOneEnitySetTwoContainersOneSchema
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void writeServiceDocumentWithOneEnitySetTwoContainersOneSchema() throws Exception {
List<EntitySet> entitySets = new ArrayList<EntitySet>();
entitySets.add(new EntitySet().setName("Employees"));
List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
entityContainers.add(new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(
entitySets));
entityContainers.add(new EntityContainer().setDefaultEntityContainer(false).setName("Container2").setEntitySets(
entitySets));
schemas.add(new Schema().setEntityContainers(entityContainers));
ODataResponse response = new AtomEntityProvider().writeServiceDocument(edm, "http://localhost");
String xmlString = verifyResponse(response);
assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString);
assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString);
assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString);
assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']", xmlString);
assertXpathExists("/a:service/a:workspace/a:collection[@href='Employees']/atom:title", xmlString);
assertXpathEvaluatesTo("Employees", "/a:service/a:workspace/a:collection[@href='Container2.Employees']/atom:title",
xmlString);
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:AtomServiceDocumentProducerTest.java
示例13: testBaseType
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void testBaseType() throws XMLStreamException, EntityProviderException {
int i = 0;
XmlMetadataConsumer parser = new XmlMetadataConsumer();
XMLStreamReader reader = createStreamReader(xmlWithBaseType);
DataServices result = parser.readMetadata(reader, true);
assertEquals("2.0", result.getDataServiceVersion());
for (Schema schema : result.getSchemas()) {
assertEquals(NAMESPACE, schema.getNamespace());
assertEquals(2, schema.getEntityTypes().size());
assertEquals("Employee", schema.getEntityTypes().get(0).getName());
for (PropertyRef propertyRef : schema.getEntityTypes().get(0).getKey().getKeys()) {
assertEquals("EmployeeId", propertyRef.getName());
}
for (Property property : schema.getEntityTypes().get(0).getProperties()) {
assertEquals(propertyNames[i], property.getName());
i++;
}
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:22,代码来源:XmlMetadataConsumerTest.java
示例14: testTwoSchemas
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void testTwoSchemas() throws XMLStreamException, EntityProviderException {
int i = 0;
String schemasNs[] = { NAMESPACE, NAMESPACE2 };
XmlMetadataConsumer parser = new XmlMetadataConsumer();
XMLStreamReader reader = createStreamReader(xmlWithTwoSchemas);
DataServices result = parser.readMetadata(reader, true);
assertEquals("2.0", result.getDataServiceVersion());
assertEquals(2, result.getSchemas().size());
for (Schema schema : result.getSchemas()) {
assertEquals(schemasNs[i], schema.getNamespace());
assertEquals(1, schema.getEntityTypes().size());
i++;
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:XmlMetadataConsumerTest.java
示例15: testAssociationSet
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void testAssociationSet() throws XMLStreamException, EntityProviderException {
XmlMetadataConsumer parser = new XmlMetadataConsumer();
XMLStreamReader reader = createStreamReader(xmlWithAssociation);
DataServices result = parser.readMetadata(reader, true);
for (Schema schema : result.getSchemas()) {
for (EntityContainer container : schema.getEntityContainers()) {
assertEquals(NAMESPACE2, schema.getNamespace());
assertEquals("Container1", container.getName());
assertEquals(Boolean.TRUE, container.isDefaultEntityContainer());
for (AssociationSet assocSet : container.getAssociationSets()) {
assertEquals(ASSOCIATION, assocSet.getName());
assertEquals(ASSOCIATION, assocSet.getAssociation().getName());
assertEquals(NAMESPACE, assocSet.getAssociation().getNamespace());
AssociationSetEnd end;
if ("Employees".equals(assocSet.getEnd1().getEntitySet())) {
end = assocSet.getEnd1();
} else {
end = assocSet.getEnd2();
}
assertEquals("r_Employees", end.getRole());
}
}
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:XmlMetadataConsumerTest.java
示例16: testAlias
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test()
public void testAlias() throws XMLStreamException, EntityProviderException {
final String xml =
"<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">"
+ "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
+ "<Schema Namespace=\"" + NAMESPACE + "\" Alias=\"RS\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
+ "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\""
+ propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>"
+ "<EntityType Name=\"Manager\" BaseType=\"RS.Employee\" m:HasStream=\"true\">" + "</EntityType>"
+ "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
XmlMetadataConsumer parser = new XmlMetadataConsumer();
XMLStreamReader reader = createStreamReader(xml);
DataServices result = parser.readMetadata(reader, true);
for (Schema schema : result.getSchemas()) {
assertEquals("RS", schema.getAlias());
for (EntityType entityType : schema.getEntityTypes()) {
if ("Manager".equals(entityType.getName())) {
assertEquals("Employee", entityType.getBaseType().getName());
assertEquals("RS", entityType.getBaseType().getNamespace());
}
}
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:XmlMetadataConsumerTest.java
示例17: writeMetadata
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void writeMetadata() throws Exception {
Map<String, String> predefinedNamespaces = new HashMap<String, String>();
predefinedNamespaces.put("annoPrefix", "http://annoNamespace");
predefinedNamespaces.put("foo", "http://foo");
predefinedNamespaces.put("annoPrefix2", "http://annoNamespace");
predefinedNamespaces.put("annoPrefix", "http://annoNamespace");
List<Schema> schemas = null;
ODataResponse response = provider.writeMetadata(schemas, predefinedNamespaces);
assertNotNull(response);
assertNotNull(response.getEntity());
assertNull("BasicProvider should not set content header", response.getContentHeader());
String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertTrue(metadata.contains("xmlns:foo=\"http://foo\""));
assertTrue(metadata.contains("xmlns:annoPrefix=\"http://annoNamespace\""));
assertTrue(metadata.contains("xmlns:annoPrefix2=\"http://annoNamespace\""));
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:BasicProviderTest.java
示例18: twoEntitySetsOneContainerForInfo
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void twoEntitySetsOneContainerForInfo() throws Exception {
List<EntitySet> entitySets = new ArrayList<EntitySet>();
EntitySet entitySet = new EntitySet().setName("Employees");
entitySets.add(entitySet);
entitySets.add(entitySet);
List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
EntityContainer container =
new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets);
entityContainers.add(container);
List<Schema> schemas = new ArrayList<Schema>();
schemas.add(new Schema().setEntityContainers(entityContainers));
EdmProvider edmProvider = mock(EdmProvider.class);
when(edmProvider.getSchemas()).thenReturn(schemas);
EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
assertNotNull(infos);
assertEquals(2, infos.size());
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:EdmServiceMetadataImplProvTest.java
示例19: oneEntitySetsOneContainerTwoSchemadForInfo
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Test
public void oneEntitySetsOneContainerTwoSchemadForInfo() throws Exception {
List<EntitySet> entitySets = new ArrayList<EntitySet>();
EntitySet entitySet = new EntitySet().setName("Employees");
entitySets.add(entitySet);
List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
EntityContainer container =
new EntityContainer().setDefaultEntityContainer(true).setName("Container").setEntitySets(entitySets);
entityContainers.add(container);
List<Schema> schemas = new ArrayList<Schema>();
schemas.add(new Schema().setEntityContainers(entityContainers));
schemas.add(new Schema().setEntityContainers(entityContainers));
EdmProvider edmProvider = mock(EdmProvider.class);
when(edmProvider.getSchemas()).thenReturn(schemas);
EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(edmProvider);
List<EdmEntitySetInfo> infos = serviceMetadata.getEntitySetInfos();
assertNotNull(infos);
assertEquals(2, infos.size());
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:EdmServiceMetadataImplProvTest.java
示例20: getSchemas
import org.apache.olingo.odata2.api.edm.provider.Schema; //导入依赖的package包/类
@Override
public List<Schema> getSchemas() throws ODataMessageException {
final Schema schema = new Schema();
schema.setNamespace(NAMESPACE_1);
schema.setEntityTypes(Arrays.asList(
getEntityType(ET_KEY_IS_STRING),
getEntityType(ET_KEY_IS_INTEGER),
getEntityType(ET_COMPLEX_KEY),
getEntityType(ET_ALL_TYPES)));
schema.setComplexTypes(Arrays.asList(getComplexType(CT_ALL_TYPES)));
final EntityContainer entityContainer = new EntityContainer();
entityContainer.setName(ENTITY_CONTAINER_1).setDefaultEntityContainer(true);
entityContainer.setEntitySets(Arrays.asList(
getEntitySet(ENTITY_CONTAINER_1, ES_KEY_IS_STRING),
getEntitySet(ENTITY_CONTAINER_1, ES_KEY_IS_INTEGER),
getEntitySet(ENTITY_CONTAINER_1, ES_COMPLEX_KEY),
getEntitySet(ENTITY_CONTAINER_1, ES_ALL_TYPES),
getEntitySet(ENTITY_CONTAINER_1, ES_STRING_FACETS)));
schema.setEntityContainers(Arrays.asList(entityContainer));
return Arrays.asList(schema);
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:TechnicalScenarioEdmProvider.java
注:本文中的org.apache.olingo.odata2.api.edm.provider.Schema类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论