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


Java EdmxFormatParser类代码示例

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


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

示例1: testInheritance

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的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

示例2: testProperty

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void testProperty() {
  XMLEventReader2 reader = StaxUtil.newXMLEventReader(new BufferedReader(
      new InputStreamReader(getClass().getResourceAsStream("/META-INF/property.xml"))));
  EdmDataServices d = new EdmxFormatParser().parseMetadata(reader);
  assertTrue("parsed", d != null);

  EdmEntityType product = d.findEdmEntitySet("Products").getType();
  EdmProperty property = product.findProperty("Name");
  assertTrue(property != null);
  assertTrue(property.getCollation() != null);
  assertTrue(property.getUnicode() != null);
  assertTrue(property.getFixedLength() != null);

  assertNotNull(property.findAnnotationElement("bla", "MyElement"));
  assertEquals("MyElement", property.findAnnotationElement("bla", "MyElement").getName());
}
 
开发者ID:teiid,项目名称:oreva,代码行数:18,代码来源:EdmxFormatParserTest.java

示例3: testAssociationEnd

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void testAssociationEnd() {
  XMLEventReader2 reader = StaxUtil.newXMLEventReader(new BufferedReader(
      new InputStreamReader(getClass().getResourceAsStream("/META-INF/associationEnd.xml"))));
  EdmDataServices d = new EdmxFormatParser().parseMetadata(reader);
  assertTrue("parsed", d != null);
  for (EdmAssociation association : d.getAssociations()) {
    if (association.getName().equals("ProductCategory")) {
      if (association.getEnd1().getRole().equals("Category")) {
        assertTrue(association.getEnd1().getOnDeleteAction() != null);
      } else {
        assertTrue(association.getEnd2().getOnDeleteAction() != null);
      }
    }
  }
}
 
开发者ID:teiid,项目名称:oreva,代码行数:17,代码来源:EdmxFormatParserTest.java

示例4: testForRecursion

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void testForRecursion() {
  XMLEventReader2 reader = StaxUtil.newXMLEventReader(new BufferedReader(
      new InputStreamReader(getClass().getResourceAsStream("/META-INF/annotation.xml"))));
  EdmDataServices d = new EdmxFormatParser().parseMetadata(reader);
  assertTrue("parsed", d != null);

  EdmAnnotationElement<?> annot = (EdmAnnotationElement<?>) d.findSchema("Example").findAnnotationElement(MYNAMESPACE, "AnnotElement");

  assertNotNull(annot);
  assertNotNull(annot.findAnnotationElement(MYNAMESPACE, "testing"));
  assertNotNull(annot.findAnnotationElement(MYNAMESPACE, "another"));

  EdmAnnotationElement<?> annot2 = (EdmAnnotationElement<?>) annot.findAnnotationElement(MYNAMESPACE, "another");
  assertEquals("bar", annot2.findAnnotation(MYNAMESPACE, "foo").getValue());
  assertNotNull(annot2.findAnnotationElement(MYNAMESPACE, "yetanother"));
  assertEquals("yetanother", annot2.findAnnotationElement(MYNAMESPACE, "yetanother").getValue().toString().trim());
  assertEquals("mynamespace", annot2.findAnnotationElement(MYNAMESPACE, "yetanother").getNamespace().getPrefix());
  assertEquals(MYNAMESPACE, annot2.findAnnotationElement(MYNAMESPACE, "yetanother").getNamespace().getUri());
}
 
开发者ID:teiid,项目名称:oreva,代码行数:21,代码来源:EdmxFormatParserTest.java

示例5: getEds

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
private EdmDataServices getEds(WSConnection conn) throws TranslatorException {
       try {
           BaseQueryExecution execution = new BaseQueryExecution(ef, null, null, conn);
           BinaryWSProcedureExecution call = execution.executeDirect("GET", "$metadata", null, execution.getDefaultHeaders()); //$NON-NLS-1$ //$NON-NLS-2$
           if (call.getResponseCode() != Status.OK.getStatusCode()) {
               throw execution.buildError(call);
           }

           Blob out = (Blob)call.getOutputParameterValues().get(0);

           EdmDataServices eds = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(out.getBinaryStream())));
           return eds;
       } catch (SQLException e) {
           throw new TranslatorException(e);
       }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:ODataMetadataProcessor.java

示例6: testSchema

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void testSchema() throws Exception {
   	translator = new ODataExecutionFactory();
   	translator.start();

	String csdl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.xml"));
	ODataMetadataProcessor processor = new ODataMetadataProcessor();
	Properties props = new Properties();
	props.setProperty("schemaNamespace", "ODataWeb.Northwind.Model");
	props.setProperty("entityContainer", "NorthwindEntities");
	MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
	processor.getMetadata(mf, new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(new ByteArrayInputStream(csdl.getBytes())))));
	
	TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "northwind", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
   	ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
   	if (report.hasItems()) {
   		throw new RuntimeException(report.getFailureMessage());
   	}		
	
	String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
	//System.out.println(ddl);	
	
	MetadataFactory mf2 = new MetadataFactory(null, 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null); 
	QueryParser.getQueryParser().parseDDL(mf2, ddl);		
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:26,代码来源:TestODataMetadataProcessor.java

示例7: testMetadata

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的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

示例8: testMetadataWithSelfJoin

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的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

示例9: getNorthwindMetadataFromODataXML

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
static TransformationMetadata getNorthwindMetadataFromODataXML() throws Exception {
	ModelMetaData model = new ModelMetaData();
	model.setName("nw");
	model.setModelType(Type.PHYSICAL);
	MetadataFactory mf = new MetadataFactory("northwind", 1, SystemMetadata.getInstance().getRuntimeTypeMap(), model);
	
	EdmDataServices edm = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new FileReader(UnitTestUtil.getTestDataFile("northwind.xml"))));
	ODataMetadataProcessor metadataProcessor = new ODataMetadataProcessor();
	PropertiesUtils.setBeanProperties(metadataProcessor, mf.getModelProperties(), "importer"); //$NON-NLS-1$
	metadataProcessor.getMetadata(mf, edm);
	
	String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
	TransformationMetadata metadata = RealMetadataFactory.fromDDL(ddl, "northwind", "nw");
   	ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
   	if (report.hasItems()) {
   		throw new RuntimeException(report.getFailureMessage());
   	}		
	return metadata;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:20,代码来源:TestDataEntitySchemaBuilder.java

示例10: setUp

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Before
  public void setUp() throws Exception {
  	translator = new ODataExecutionFactory();
  	translator.start();
  	
String csdl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.xml"));
EdmDataServices eds = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(new ByteArrayInputStream(csdl.getBytes()))));
ODataMetadataProcessor processor = new ODataMetadataProcessor();
Properties props = new Properties();
props.setProperty("schemaNamespace", "ODataWeb.Northwind.Model");
props.setProperty("entityContainer", "NorthwindEntities");
MetadataFactory mf = new MetadataFactory("vdb", 1, "nw", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);

processor.getMetadata(mf, eds);

TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "northwind", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
  	ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
  	if (report.hasItems()) {
  		throw new RuntimeException(report.getFailureMessage());
  	}
  	//TransformationMetadata metadata = RealMetadataFactory.fromDDL(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.ddl")), "northwind", "nw");
  	utility = new TranslationUtility(metadata);
  }
 
开发者ID:kenweezy,项目名称:teiid,代码行数:24,代码来源:TestODataSQLVistor.java

示例11: issue186

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void issue186() {
  InputStream metadataStream = getClass().getResourceAsStream("/META-INF/issue186_netflix_metadata.xml");
  XMLEventReader2 reader = XMLFactoryProvider2.getInstance().newXMLInputFactory2().createXMLEventReader(new InputStreamReader(metadataStream));
  EdmDataServices metadata = new EdmxFormatParser().parseMetadata(reader);

  InputStream titlesStream = getClass().getResourceAsStream("/META-INF/issue186_netflix_titles.xml");
  AtomFeed feed = new AtomFeedFormatParser(metadata, "Titles", null, null, null).parse(new InputStreamReader(titlesStream));
  Assert.assertNotNull(feed);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:11,代码来源:Issue186Test.java

示例12: issue187

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void issue187() {
  InputStream metadataStream = getClass().getResourceAsStream("/META-INF/issue187_lightswitch_metadata.xml");
  XMLEventReader2 reader = XMLFactoryProvider2.getInstance().newXMLInputFactory2().createXMLEventReader(new InputStreamReader(metadataStream));
  EdmDataServices metadata = new EdmxFormatParser().parseMetadata(reader);
  Assert.assertNotNull(metadata);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:8,代码来源:Issue187Test.java

示例13: issue98

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void issue98() {
  InputStream metadataStream = getClass().getResourceAsStream("/META-INF/issue98_metadata.xml");
  XMLEventReader2 reader = XMLFactoryProvider2.getInstance().newXMLInputFactory2().createXMLEventReader(new InputStreamReader(metadataStream));
  EdmDataServices metadata = new EdmxFormatParser().parseMetadata(reader);

  InputStream titlesStream = getClass().getResourceAsStream("/META-INF/issue98_payload.json");
  Settings settings = new Settings(ODataVersion.V1, metadata, "People", null, null);
  Feed feed = new JsonFeedFormatParser(settings).parse(new InputStreamReader(titlesStream));
  Assert.assertNotNull(feed);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:12,代码来源:Issue98Test.java

示例14: issue212

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void issue212() {
  InputStream metadataStream = getClass().getResourceAsStream("/META-INF/issue212_wxcex_metadata.xml");
  XMLEventReader2 reader = XMLFactoryProvider2.getInstance().newXMLInputFactory2().createXMLEventReader(new InputStreamReader(metadataStream));
  EdmDataServices metadata = new EdmxFormatParser().parseMetadata(reader);
  Assert.assertNotNull(metadata);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:8,代码来源:Issue212Test.java

示例15: parseSapDsSample

import org.odata4j.format.xml.EdmxFormatParser; //导入依赖的package包/类
@Test
public void parseSapDsSample() {
  XMLEventReader2 reader = StaxUtil.newXMLEventReader(new BufferedReader(
      new InputStreamReader(getClass().getResourceAsStream(sapDsSampleEdmxFile))));
  EdmDataServices d = new EdmxFormatParser().parseMetadata(reader);
  assertTrue("parsed", d != null);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:8,代码来源:EdmxFormatParserTest.java


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