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


Java EdmxFormatWriter类代码示例

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


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

示例1: createUserDataSchemaCache

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
private Map<String, Object> createUserDataSchemaCache() {
    // キャッシュしてみる
    Map<String, Object> cache;
    cache = new HashMap<String, Object>();
    cache.put("entityTypeIds", this.entityTypeIds);
    cache.put("propertyAliasMap", getPropertyAliasMap());
    cache.put("entityTypeMap", getEntityTypeMap());
    StringWriter w = new StringWriter();
    EdmxFormatWriter.write(this.metadata, w);

    // 制御コードが含まれていた場合は、キャッシュしない(エスケープ・アンエスケープの必要があるため)
    if (EscapeControlCode.isContainsControlChar(w.toString())) {
        return null;
    }
    cache.put("edmx", w.toString());
    return cache;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:18,代码来源:UserDataODataProducer.java

示例2: testEntityType

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testEntityType() throws XpathException, IOException, SAXException {

  EdmEntityType.Builder productBuilder = EdmEntityType.newBuilder();
  productBuilder = productBuilder.setName("Product").setOpenType(OPENTYPE_TRUE).addKeys("ProductId");
  EdmSchema.Builder schema = EdmSchema.newBuilder().setNamespace(SCHEMA);
  schema.addEntityTypes(productBuilder);

  EdmDataServices.Builder serviceBuilder = EdmDataServices.newBuilder().addSchemas(schema);
  EdmDataServices edmService = serviceBuilder.build();

  StringWriter writer = new StringWriter();
  EdmxFormatWriter.write(edmService, writer);
  String xml2 = writer.toString();

  assertThat(xml2, containsString("<EntityType OpenType=\"true\" Name=\"Product\">"));
  Document inDocument = XMLUnit.buildControlDocument(xml2);

  assertXpathExists("//edm:Schema/edm:EntityType/@OpenType", xml2);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:21,代码来源:EdmxFormatWriterTest.java

示例3: testContainer

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testContainer() throws XpathException, IOException, SAXException {
  EdmEntityContainer.Builder entityContainer2 = EdmEntityContainer.newBuilder()
      .setName("Container2")
      .setExtendz("Container")
      .setLazyLoadingEnabled(true);

  schema.addEntityContainers(container, entityContainer2);

  EdmDataServices.Builder builder = EdmDataServices.newBuilder().addSchemas(schema);
  EdmDataServices edmService = builder.build();
  StringWriter writer = new StringWriter();
  EdmxFormatWriter.write(edmService, writer);
  String xml = writer.toString();

  assertThat(xml, containsString("Extends=\"Container\""));
  assertThat(xml, containsString("LazyLoadingEnabled=\"true\""));

  assertXpathExists("//edm:Schema/edm:EntityContainer/@Extends", xml);
  assertXpathExists("//edm:Schema/edm:EntityContainer/@annotation:LazyLoadingEnabled", xml);

}
 
开发者ID:teiid,项目名称:oreva,代码行数:23,代码来源:EdmxFormatWriterTest.java

示例4: testInheritance

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testInheritance() throws FileNotFoundException, InterruptedException {

  // do the raw xml first...
  XMLEventReader2 reader = StaxUtil.newXMLEventReader(new BufferedReader(
      new InputStreamReader(getClass().getResourceAsStream(edmxFile))));
  EdmDataServices d = new EdmxFormatParser().parseMetadata(reader);
  assertTrue("parsed", d != null);

  checkTypeHierarchy(d);

  // now take the parsed result, back to xml, re-parse, check that...
  StringWriter sw = new StringWriter();
  EdmxFormatWriter.write(d, sw);

  EdmDataServices d2 = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new StringReader(sw.toString())));
  assertTrue("parsed", d2 != null);

  checkTypeHierarchy(d2);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:21,代码来源:EdmxFormatParserTest.java

示例5: testMetadataVisibility

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testMetadataVisibility() throws Exception {
    Client client = mockClient2();
    MockProvider.CLIENT = client;
    
    StringWriter sw = new StringWriter();
    
    EdmxFormatWriter.write(client.getMetadata(), sw);
    
    ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/$metadata"));
    ClientResponse<String> response = request.get(String.class);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(sw.toString(), response.getEntity());  
    String edm = "<?xml version=\"1.0\" encoding=\"utf-8\"?><edmx:Edmx Version=\"1.0\" xmlns:edmx=\"http://schemas.microsoft.com/ado/2007/06/edmx\"><edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"></edmx:DataServices></edmx:Edmx>";
    Assert.assertEquals(edm, response.getEntity());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:TestODataIntegration.java

示例6: testMetadata

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testMetadata() throws Exception {
	TransformationMetadata metadata = RealMetadataFactory.fromDDL(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.ddl")), "northwind", "nw");		
	StringWriter sw = new StringWriter();
	EdmDataServices eds = ODataEntitySchemaBuilder.buildMetadata(metadata.getMetadataStore());
	EdmxFormatWriter.write(eds, sw);
	
	//System.out.println(sw.toString());
    EdmDataServices pds = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new StringReader(sw.toString())));
    
    assertEquals(eds.getSchemas().size(), pds.getSchemas().size());
    
    for (int i = 0; i < eds.getSchemas().size(); i++) {
    	EdmSchema expected = eds.getSchemas().get(i);
    	EdmSchema actual = pds.getSchemas().get(i);
    	assertEdmSchema(expected, actual);
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:TestDataEntitySchemaBuilder.java

示例7: testMetadataWithSelfJoin

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testMetadataWithSelfJoin() throws Exception {
    TransformationMetadata metadata = RealMetadataFactory.fromDDL(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("categories.ddl")), "northwind", "nw");       
    StringWriter sw = new StringWriter();
    EdmDataServices eds = ODataEntitySchemaBuilder.buildMetadata(metadata.getMetadataStore());
    EdmxFormatWriter.write(eds, sw);
    
    String expectedXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?><edmx:Edmx Version=\"1.0\" xmlns:edmx=\"http://schemas.microsoft.com/ado/2007/06/edmx\"><edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><Schema Namespace=\"nw\" xmlns=\"http://schemas.microsoft.com/ado/2008/09/edm\"><EntityType Name=\"Category\"><Key><PropertyRef Name=\"CategoryID\"></PropertyRef></Key><Property Name=\"CategoryID\" Type=\"Edm.Int32\" Nullable=\"false\"></Property><Property Name=\"Name\" Type=\"Edm.String\" Nullable=\"false\" MaxLength=\"25\" FixedLength=\"false\" Unicode=\"true\"></Property><Property Name=\"ParentCategoryID\" Type=\"Edm.Int32\" Nullable=\"false\"></Property><NavigationProperty Name=\"Category\" Relationship=\"nw.Category_FK_CATEGORY_ID\" FromRole=\"Category\" ToRole=\"Category\"></NavigationProperty></EntityType><Association Name=\"Category_FK_CATEGORY_ID\"><End Type=\"nw.Category\" Multiplicity=\"*\" Role=\"Category\"></End><End Type=\"nw.Category\" Multiplicity=\"0..1\" Role=\"Category\"></End><ReferentialConstraint><Principal Role=\"Category\"><PropertyRef Name=\"CategoryID\"></PropertyRef></Principal><Dependent Role=\"Category\"><PropertyRef Name=\"ParentCategoryID\"></PropertyRef></Dependent></ReferentialConstraint></Association><EntityContainer Name=\"nw\" m:IsDefaultEntityContainer=\"false\"><EntitySet Name=\"Category\" EntityType=\"nw.Category\"></EntitySet><AssociationSet Name=\"Category_FK_CATEGORY_ID\" Association=\"nw.Category_FK_CATEGORY_ID\"><End EntitySet=\"Category\" Role=\"Category\"></End><End EntitySet=\"Category\" Role=\"Category\"></End></AssociationSet></EntityContainer></Schema></edmx:DataServices></edmx:Edmx>\n";        		
    EdmDataServices pds = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new StringReader(expectedXML)));
    
    assertEquals(eds.getSchemas().size(), pds.getSchemas().size());
    
    for (int i = 0; i < eds.getSchemas().size(); i++) {
        EdmSchema expected = eds.getSchemas().get(i);
        EdmSchema actual = pds.getSchemas().get(i);
        assertEdmSchema(expected, actual);
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:TestDataEntitySchemaBuilder.java

示例8: doGetMetadata

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
/**
 * サービスメタデータリクエストに対応する.
 * @return JAX-RS 応答オブジェクト
 */
protected Response doGetMetadata() {

    StringWriter w = new StringWriter();
    EdmxFormatWriter.write(this.metadata, w);
    return Response.ok(w.toString(), ODataConstants.APPLICATION_XML_CHARSET_UTF8)
            .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataConstants.DATA_SERVICE_VERSION_HEADER)
            .build();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:13,代码来源:ODataResource.java

示例9: getMetadata

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@GET
@Produces({ ODataConstants.APPLICATION_XML_CHARSET_UTF8, ODataConstants.APPLICATION_ATOMSVC_XML_CHARSET_UTF8 })
public Response getMetadata(
    @Context HttpHeaders httpHeaders,
    @Context UriInfo uriInfo,
    @Context ContextResolver<ODataProducer> producerResolver,
    @QueryParam("$format") String format) {

  ODataProducer producer = producerResolver.getContext(ODataProducer.class);

  // a request for media type atomsvc+xml means give me the service document of the metadata producer
  if ("atomsvc".equals(format) || isAtomSvcRequest(httpHeaders)) {
    MetadataProducer metadataProducer = producer.getMetadataProducer();
    if (metadataProducer == null) {
      throw newMetadataNotImplementedException();
    }
    ServiceDocumentResource r = new ServiceDocumentResource();
    return r.getServiceDocument(httpHeaders, uriInfo, producerResolver, FormatType.ATOM.name(), null);
  } else {
    StringWriter w = new StringWriter();
    ODataProducer source = "metamodel".equals(format) ? producer.getMetadataProducer() : producer;
    if (source == null) {
      throw newMetadataNotImplementedException();
    }
    EdmDataServices s = source.getMetadata();
    EdmxFormatWriter.write(s, w);

    return Response.ok(w.toString(), ODataConstants.APPLICATION_XML_CHARSET_UTF8)
        .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataConstants.DATA_SERVICE_VERSION_HEADER)
        .build();
  }
}
 
开发者ID:teiid,项目名称:oreva,代码行数:33,代码来源:MetadataResource.java

示例10: testPrecisionAndScale

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testPrecisionAndScale() {

  // build simplest edm containing one decimal property
  EdmProperty.Builder edmPropertyBuilder = EdmProperty.newBuilder("DecimalProperty").setType(EdmSimpleType.DECIMAL).setPrecision(2).setScale(10);
  List<EdmProperty.Builder> builderProperties = new ArrayList<EdmProperty.Builder>();
  builderProperties.add(edmPropertyBuilder);

  List<String> keys = new ArrayList<String>();
  keys.add("DecimalProperty");

  EdmEntityType.Builder entityTypeBuilder = EdmEntityType.newBuilder().setName("TypeName");
  entityTypeBuilder.addProperties(builderProperties);
  entityTypeBuilder.addKeys(keys);

  ArrayList<EdmEntityType.Builder> builderEntityTypes = new ArrayList<EdmEntityType.Builder>();
  builderEntityTypes.add(entityTypeBuilder);

  EdmSchema.Builder edmSchemaBuilder = EdmSchema.newBuilder().setNamespace("Namespace");
  edmSchemaBuilder.addEntityTypes(builderEntityTypes);

  EdmDataServices.Builder edmDataServiceBuilder = EdmDataServices.newBuilder();
  edmDataServiceBuilder.addSchemas(edmSchemaBuilder);

  // print xml
  StringWriter sw = new StringWriter();
  EdmxFormatWriter.write(edmDataServiceBuilder.build(), sw);
  String edmAsString = sw.toString();

  // check it
  assertTrue(edmAsString.contains("<Property Name=\"DecimalProperty\" Type=\"Edm.Decimal\" Nullable=\"false\" Precision=\"2\" Scale=\"10\"></Property>"));
}
 
开发者ID:teiid,项目名称:oreva,代码行数:33,代码来源:Issue177Test.java

示例11: testMetadata

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testMetadata() throws Exception {
	Client client = mockClient();
	MockProvider.CLIENT = client;
	
	StringWriter sw = new StringWriter();
	
	EdmxFormatWriter.write(client.getMetadata(), sw);
	
       ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/$metadata"));
       ClientResponse<String> response = request.get(String.class);
       Assert.assertEquals(200, response.getStatus());
       Assert.assertEquals(sw.toString(), response.getEntity());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:15,代码来源:TestODataIntegration.java

示例12: dump

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
public void dump() {
  StringWriter sw = new StringWriter();
  EdmxFormatWriter.write(edm, sw);
  System.out.println(sw.toString());
}
 
开发者ID:teiid,项目名称:oreva,代码行数:6,代码来源:MetadataProducer.java

示例13: testReferentialConstraint

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testReferentialConstraint() throws XpathException, IOException, SAXException {

  EdmEntityType.Builder employee = EdmEntityType.newBuilder()
      .setName("Employee")
      .setNamespace(NAMESPACE)
      .addKeys("EmployeeID");
  EdmEntityType.Builder manager = EdmEntityType.newBuilder()
      .setName("Manager")
      .setNamespace(NAMESPACE)
      .addKeys("ManagerID");
  List<EdmAssociation.Builder> associations = new ArrayList<EdmAssociation.Builder>();
  EdmAssociationEnd.Builder from = EdmAssociationEnd.newBuilder()
      .setRole("Employees")
      .setType(employee)
      .setMultiplicity(EdmMultiplicity.ONE);
  EdmAssociationEnd.Builder to = EdmAssociationEnd.newBuilder()
      .setRole("Manager")
      .setType(manager)
      .setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);

  EdmReferentialConstraint.Builder constraint = EdmReferentialConstraint.newBuilder().setPrincipalRole("Employee").setDependentRole("Manager");
  constraint = constraint.addPrincipalReferences("EmployeeID").addDependentReferences("ManagerID");
  associations.add(EdmAssociation.newBuilder().setName("EmployeeManager").setEnds(from, to).setRefConstraint(constraint));
  schema.addAssociations(associations);
  EdmDataServices.Builder serviceBuilder = EdmDataServices.newBuilder().addSchemas(schema);
  EdmDataServices edmService = serviceBuilder.build();

  StringWriter writer = new StringWriter();
  EdmxFormatWriter.write(edmService, writer);
  String xml = writer.toString();

  assertThat(xml, containsString("<ReferentialConstraint>"));
  assertThat(xml, containsString("<Principal Role=\"Employee\">"));
  assertThat(xml, containsString("<Dependent Role=\"Manager\">"));
  assertThat(xml, containsString("<PropertyRef Name=\"EmployeeID\">"));
  assertThat(xml, containsString("<PropertyRef Name=\"ManagerID\">"));

  assertXpathExists("//edm:Schema/edm:Association/edm:ReferentialConstraint", xml);
  assertXpathExists("//edm:Schema/edm:Association/edm:ReferentialConstraint/edm:Principal/@Role", xml);
  assertXpathExists("//edm:Schema/edm:Association/edm:ReferentialConstraint/edm:Dependent/@Role", xml);
  assertXpathExists("//edm:Schema/edm:Association/edm:ReferentialConstraint/edm:Dependent/edm:PropertyRef/@Name", xml);

}
 
开发者ID:teiid,项目名称:oreva,代码行数:45,代码来源:EdmxFormatWriterTest.java

示例14: testProperty

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testProperty() throws XpathException, IOException, SAXException {
  List<EdmProperty.Builder> properties = new ArrayList<EdmProperty.Builder>();
  EdmEntityType.Builder product = EdmEntityType.newBuilder().setNamespace(NAMESPACE);
  product = product.setName("Product").addKeys("ProductId");
  EdmProperty.Builder property = EdmProperty.newBuilder("ProductId").setType(EdmSimpleType.INT32).setNullable(false);
  properties.add(property);

  property = EdmProperty.newBuilder("Name").setType(EdmSimpleType.STRING).setFixedLength(true);
  property = property.setUnicode(true).setCollation(COLLATING_SEQUENCE);
  properties.add(property);
  product.addProperties(properties);

  // .........................................................................
  EdmAnnotationElement<String> elem = EdmAnnotation.element("bla", "myns", "myProperty", String.class, "hello");

  EdmAnnotationAttribute attr = EdmAnnotation.attribute("blabla", "myns2", "Name", "hello");
  List<EdmAnnotation<?>> annotationAttributes = new ArrayList<EdmAnnotation<?>>();
  annotationAttributes.add(attr);
  elem.setAnnotations(annotationAttributes);

  List<EdmAnnotation<?>> annotations2 = new ArrayList<EdmAnnotation<?>>();
  annotations2.add(elem);

  product.setAnnotationElements(annotations2);
  // .............................................................................
  productSet.setEntityType(product);
  container.addEntitySets(productSet);
  schema.addEntityTypes(product);
  schema.setAlias("xmlns:myns2=blabla");
  schema.setAnnotations(annotationAttributes);
  schema.addEntityContainers(container);

  List<PrefixedNamespace> pnList = new ArrayList<PrefixedNamespace>();
  pnList.add(new PrefixedNamespace("htp://sample.url", "myns2"));

  EdmDataServices.Builder serviceBuilder = EdmDataServices.newBuilder().addSchemas(schema).addNamespaces(pnList);
  EdmDataServices edmService = serviceBuilder.build();

  StringWriter writer = new StringWriter();
  EdmxFormatWriter.write(edmService, writer);
  String xml = writer.toString();

  assertThat(xml, containsString("FixedLength=\"true\""));
  assertThat(xml, containsString("Unicode=\"true\""));
  assertThat(xml, containsString("Collation=\"DIN 5007-1\""));

  assertXpathExists("//edm:Schema/edm:EntityType/edm:Property/@FixedLength", xml);
  assertXpathExists("//edm:Schema/edm:EntityType/edm:Property/@Unicode", xml);
  assertXpathExists("//edm:Schema/edm:EntityType/edm:Property/@Collation", xml);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:52,代码来源:EdmxFormatWriterTest.java

示例15: testAssociationEnd

import org.odata4j.format.xml.EdmxFormatWriter; //导入依赖的package包/类
@Test
public void testAssociationEnd() throws XpathException, IOException, SAXException {
  EdmEntityType.Builder product = EdmEntityType.newBuilder()
      .setName("Product")
      .setNamespace(NAMESPACE)
      .addKeys("ProductID");
  EdmEntityType.Builder category = EdmEntityType.newBuilder()
      .setName("Category")
      .setNamespace(NAMESPACE)
      .addKeys("CategoryID");

  List<EdmAssociation.Builder> associations = new ArrayList<EdmAssociation.Builder>();

  EdmAssociationEnd.Builder fromRole = EdmAssociationEnd.newBuilder().setRole("Product");
  fromRole = fromRole.setType(product);
  fromRole = fromRole.setMultiplicity(EdmMultiplicity.MANY);

  EdmAssociationEnd.Builder toRole = EdmAssociationEnd.newBuilder().setRole("Category");
  toRole = toRole.setType(category);
  toRole = toRole.setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
  toRole = toRole.setOnDeleteAction(EdmOnDeleteAction.CASCADE);
  associations.add(EdmAssociation.newBuilder().setName("ProductCategory").setEnds(fromRole, toRole));

  productSet.setEntityType(product);
  categorySet.setEntityType(category);
  container.addEntitySets(productSet);
  schema.addEntityTypes(product);
  schema.addEntityContainers(container);
  schema.addAssociations(associations);
  EdmDataServices.Builder serviceBuilder = EdmDataServices.newBuilder().addSchemas(schema);
  EdmDataServices edmService = serviceBuilder.build();

  StringWriter writer = new StringWriter();
  EdmxFormatWriter.write(edmService, writer);
  String xml = writer.toString();

  assertThat(xml, containsString("<OnDelete Action=\"Cascade\">"));

  assertXpathExists("//edm:Schema/edm:Association/edm:End/edm:OnDelete/@Action", xml);

}
 
开发者ID:teiid,项目名称:oreva,代码行数:42,代码来源:EdmxFormatWriterTest.java


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