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


Java Schema类代码示例

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


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


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