tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malisetti, Ramanjaneyulu" <Ramanjaneyulu.Malise...@ca.com>
Subject RE: How to add types in SDO on the fly?
Date Wed, 05 Dec 2012 15:03:11 GMT
Thanks a lot Sebastian,  this is good. I  have another question related to XSDHelper.define(XSD).
Suppose if I load XSD say abc.xsd using XSDHelper.define() and then load same file with new
types.  New types are not available as loading XSD is skipped due XSDHelper thinking this
schema is already loaded. How to overcome this problem?

Regards
Raman

From: Millies, Sebastian [mailto:Sebastian.Millies@softwareag.com]
Sent: Wednesday, December 05, 2012 8:19 PM
To: user@tuscany.apache.org
Subject: RE: How to add types in SDO on the fly?

Hello Raman,

here’s an example :


private Type theType;

private void createType()
  {
    HelperContext ctx = HelperProvider.getDefaultContext();
    // define a new type
    DataObject typeDef = ctx.getDataFactory().create( "commonj.sdo", "Type" );
    typeDef.set( "uri", "http://namespacei/file" );
    typeDef.set( "name", "FileType" );
    // add properties
    DataObject propDef;
    propDef = typeDef.createDataObject( "property" );
    propDef.set( "name", "id" );
    propDef.set( "type", ctx.getTypeHelper().getType( "commonj.sdo", "String" ) );
    propDef = typeDef.createDataObject( "property" );
    propDef.set( "name", "fileName" );
    propDef.set( "type", ctx.getTypeHelper().getType( "commonj.sdo", "String" ) );
    propDef = typeDef.createDataObject( "property" );
    propDef.set( "name", "lastModified" );
    propDef.set( "type", ctx.getTypeHelper().getType( "commonj.sdo", "Date" ) );
    propDef = typeDef.createDataObject( "property" );
    propDef.set( "name", "length" );
    propDef.set( "type", ctx.getTypeHelper().getType( "commonj.sdo", "Long" ) );
    // define the type
    theType = ctx.getTypeHelper().define( typeDef );
  }


SDOs can be created just like XSD-based ones, e.g.

private DataObject createDataObject( File file )
  {
    HelperContext ctx = HelperProvider.getDefaultContext();
    DataFactory df = ctx.getDataFactory();
  // create object of dynamically defined type
    DataObject sdo = df.create( theType );
    sdo.setString( "id", file.getPath() );
    sdo.setString( "fileName", file.getName() );
    sdo.setDate( "lastModified", new Date() );
    return sdo;
  }


•  Sebastian

From: Malisetti, Ramanjaneyulu [mailto:Ramanjaneyulu.Malisetti@ca.com]
Sent: Wednesday, December 05, 2012 1:32 PM
To: user@tuscany.apache.org<mailto:user@tuscany.apache.org>
Subject: How to add types in SDO on the fly?

Hi,
       I am familiar with XSDHelper.define(XSD) to load types into SDO runtime. We have a
requirement to add types at runtime without XSD file. How to achieve that? Any idea?

Regards
Raman
IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Michael Rehm, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial
register: Saarbrücken HRB 19681
http://www.ids-scheer-consulting.com


Mime
View raw message