tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Millies, Sebastian" <Sebastian.Mill...@softwareag.com>
Subject RE: How to add types in SDO on the fly?
Date Wed, 05 Dec 2012 14:49:10 GMT
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;
  }


n  Sebastian

From: Malisetti, Ramanjaneyulu [mailto:Ramanjaneyulu.Malisetti@ca.com]
Sent: Wednesday, December 05, 2012 1:32 PM
To: 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