You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jean-Sebastien Delfino <js...@apache.org> on 2006/08/22 22:09:57 UTC

[C++] Creating an SDO DataObject for the properties of a component

I'd like to get some basic property support in place to be able to 
configure component properties in the SupplyChain scenario that I'm 
working on.

In an SCDL componentType file I have this for example:
    <property name="currency" type="xs:string"/>
    <property name="discount" type="xs:double"/>
defining property names and types.

In my SCDL component declaration I have this:
<component ...>
  <property name="currency"/>USD</property>
  <property name="discount"/>10</property>
</component>

In the ModelLoader we are using the SDO runtime to load the <component> 
SCDL so we already have in hand a DataObject representing the 
<component>, containing a list of <property> DataObjects.
Now I need to dynamically create a new SDO type containing SDO 
properties for currency and discount (of types string and double), then 
create a DataObject of that type with its properties set to USD and 10.
This DataObject will be returned by ComponentContext.getProperties(), 
allowing my application code to do the following:
DataObject properties=componentContext.getProperties();
properties.getCString("currency"); -> returns USD
properties.getDouble("discount"); -> returns 10

I'm going in circles trying to find the simplest way to dynamically 
create this new DataObject type. Could one of our SDO experts help me 
understand how to do this?
I accept code too, so if you just give me a magic code snippet showing 
how to create this SDO type with its SDO properties and move the values 
into an instance of it, that's even better :)

Thanks

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Pete Robbins <ro...@googlemail.com>.
I've checked in code to support simple type properties. Need to figure out
how we load the schema for any complex type properties. Don't think this
will be too hard.

Cheers,


On 23/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>
> Pete Robbins wrote:
> > Sebastien, I'm fixing this. It shouldn't take long.
> >
> > Cheers,
> >
> >
> > On 22/08/06, Pete Robbins <ro...@googlemail.com> wrote:
> >>
> >> ah!
> >>
> >>  On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
> >>
> >> >
> >> > It doesn't work at all now. With SCDL 0.9 a component declaration
> >> looked
> >> > like that:
> >> > <component>
> >> > <properties>
> >> >      <v:Fred>abc</v:Fred>
> >> >      <v:Joe>xyz</v:Joe>
> >> >     <v:Joe>tuv</v:Joe>
> >> > </properties>
> >> > </component>
> >> >
> >> > The DataObject loaded from that looked exactly like what the client
> >> Cpp
> >> > code expected, allowing you to code
> >> > ComponentContext.getProperties()->getCString("Fred")...
> >> >
> >> > SCDL 0.95 now looks pretty different:
> >> > <component>
> >> >    <property name="Fred">abc</property>
> >> >    <property name="Joe">xyz</property>
> >> >   <property name="Joe">tuv</property>
> >> > </component>
> >> >
> >> > ... missing the convenient <properties> parent element and in a very
> >> > different form now. I'm guessing that we don't want the client code
> to
> >> > change, so we need to massage the DataObject loaded from SCDL to look
> >> > like what the client code wants to see. The other thing is that we
> >> > should use the property types specified in the component type
> >> instead of
> >> > guessing the types from the instance properties in the component
> >> > declaration.
> >> >
> >> > So I'm basically trying to fix ModelLoader to created the expected
> >> > DataObject from what we get from SCDL. In the SupplyChain scenario I
> >> > have multiple Manufacturer and Warehouse components, same
> >> implementation
> >> > but configured with different properties so I need to get this
> >> property
> >> > stuff working...
> >>
> >>
> >>  Ok I understand the problem. I wasn't up to date with the latest
> >> definition of properties. If the current interface to properties is not
> >> workable then we can always feed that back to the spec group. Anyho...
> >>
> >> I think what we need to do is
> >> 1)create a DataFactory for the properties and populate it with the
> types
> >> required for the properties (basic xml types will be there by default
> >> but
> >> any user defined complex types will have to be defined in a schema
> >> somewhere
> >> so lets stick to simple types for now).
> >> 2) When loading the definitions of the properties from the
> componentType
> >> we need to create a new SDO Type for properties associated with this
> >> component and add it to the DataFactory. So we would do something like:
> >>
> >> dataFactory->addType("someNamespace", "componentProperties", ....)
> >> dataFactory->addPropertyToType((<propertyName>, <propType>.... for
> >> each of
> >> the properties defined)
> >>
> >> 3) create a DO of "someNamespace", "componentProperties" type and
> >> save the
> >> DOPtr in the Component defintion in the model
> >> 4) For each property set
> >>  propertyDO->set(<propertyName>, value)
> >> 5) ComponentContext::GetProperties will return the propertyDO from the
> >> Component
> >>
> >> voila!
> >>
> >> So we need to create a datafactory per componentType I think.
> >>
> >> --
> >> Pete
> >>
> >
> >
> >
>
> Cool, Thanks!
>
> --
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>


-- 
Pete

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Pete Robbins <ro...@googlemail.com>.
Yay!

On 23/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>
> Pete Robbins wrote:
> > On 23/08/06, Geoffrey Winn <geoff.winn@googlemail.com > wrote:
> >
> >> Sebastien, Pete,
> >>
> >> I may have misunderstood the base note, however, it looks to me that
> you
> >> are
> >> trying to make changes to the metadata - by adding types - after
> >> creating
> >> a
> >> data object.
> >>
> >> > so we already have in hand a DataObject representing the
> >> > <component>, containing a list of <property> DataObjects.
> >> > Now I need to dynamically create a new SDO type containing
> >>
> >> If I'm right then this is a known restricion. We have a JIRA
> >> (TUSCANY-474)
> >> that explains it. Bascally, as soon as you create a data object the
> type
> >> system is frozen. Pete, is that why you are suggesting creating a
> >> DataFactory for each componenType?
> >
> >
> > Exactly! However my brain let me down as when I went to check the code
> > I had
> > already coded it this way ;-)
> >
> > What we do need is a way of setting the default value for a type.
> > Maybe you
> > can enlighten me on what I have to do. Is there code to handle default
> > values in SDO?
> >
> > Cheers,
> >
> Pete,
>
> With your last check-in, simple type properties now work. The BigBank
> Account service gets its property correctly set up to EURO. Thanks!
>
> --
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>


-- 
Pete

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Pete Robbins wrote:
> On 23/08/06, Geoffrey Winn <ge...@googlemail.com> wrote:
>
>> Sebastien, Pete,
>>
>> I may have misunderstood the base note, however, it looks to me that you
>> are
>> trying to make changes to the metadata - by adding types - after 
>> creating
>> a
>> data object.
>>
>> > so we already have in hand a DataObject representing the
>> > <component>, containing a list of <property> DataObjects.
>> > Now I need to dynamically create a new SDO type containing
>>
>> If I'm right then this is a known restricion. We have a JIRA 
>> (TUSCANY-474)
>> that explains it. Bascally, as soon as you create a data object the type
>> system is frozen. Pete, is that why you are suggesting creating a
>> DataFactory for each componenType?
>
>
> Exactly! However my brain let me down as when I went to check the code 
> I had
> already coded it this way ;-)
>
> What we do need is a way of setting the default value for a type. 
> Maybe you
> can enlighten me on what I have to do. Is there code to handle default
> values in SDO?
>
> Cheers,
>
Pete,

With your last check-in, simple type properties now work. The BigBank 
Account service gets its property correctly set up to EURO. Thanks!

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Geoffrey Winn <ge...@googlemail.com>.
Oh I give up! I meant DataFactoryImpl not DataObjectImpl in the previous
post.

Regards,

Geoff.

On 23/08/06, Geoffrey Winn <ge...@googlemail.com> wrote:
>
> Pete,
>
> The DataObjectImpl class has a variety of public setDefault methods that
> will set a default value for a property of a type. Is that what you a
> looking for?
>
> Also, I fumbled the JIRA reference earlier. The JIRA to add a flexible
> type system is TUSCANY-546
>
> Regards,
>
> Geoff.
>
>
> On 23/08/06, Pete Robbins <ro...@googlemail.com> wrote:
> >
> > On 23/08/06, Geoffrey Winn <ge...@googlemail.com> wrote:
> >
> > > Sebastien, Pete,
> > >
> > > I may have misunderstood the base note, however, it looks to me that
> > you
> > > are
> > > trying to make changes to the metadata - by adding types - after
> > creating
> > > a
> > > data object.
> > >
> > > > so we already have in hand a DataObject representing the
> > > > <component>, containing a list of <property> DataObjects.
> > > > Now I need to dynamically create a new SDO type containing
> > >
> > > If I'm right then this is a known restricion. We have a JIRA
> > (TUSCANY-474)
> > > that explains it. Bascally, as soon as you create a data object the
> > type
> > > system is frozen. Pete, is that why you are suggesting creating a
> > > DataFactory for each componenType?
> >
> >
> > Exactly! However my brain let me down as when I went to check the code I
> > had
> > already coded it this way ;-)
> >
> > What we do need is a way of setting the default value for a type. Maybe
> > you
> > can enlighten me on what I have to do. Is there code to handle default
> > values in SDO?
> >
> > Cheers,
> >
> > --
> > Pete
> >
> >
>

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Geoffrey Winn <ge...@googlemail.com>.
Pete,

The DataObjectImpl class has a variety of public setDefault methods that
will set a default value for a property of a type. Is that what you a
looking for?

Also, I fumbled the JIRA reference earlier. The JIRA to add a flexible type
system is TUSCANY-546

Regards,

Geoff.

On 23/08/06, Pete Robbins <ro...@googlemail.com> wrote:
>
> On 23/08/06, Geoffrey Winn <ge...@googlemail.com> wrote:
>
> > Sebastien, Pete,
> >
> > I may have misunderstood the base note, however, it looks to me that you
> > are
> > trying to make changes to the metadata - by adding types - after
> creating
> > a
> > data object.
> >
> > > so we already have in hand a DataObject representing the
> > > <component>, containing a list of <property> DataObjects.
> > > Now I need to dynamically create a new SDO type containing
> >
> > If I'm right then this is a known restricion. We have a JIRA
> (TUSCANY-474)
> > that explains it. Bascally, as soon as you create a data object the type
> > system is frozen. Pete, is that why you are suggesting creating a
> > DataFactory for each componenType?
>
>
> Exactly! However my brain let me down as when I went to check the code I
> had
> already coded it this way ;-)
>
> What we do need is a way of setting the default value for a type. Maybe
> you
> can enlighten me on what I have to do. Is there code to handle default
> values in SDO?
>
> Cheers,
>
> --
> Pete
>
>

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Pete Robbins <ro...@googlemail.com>.
On 23/08/06, Geoffrey Winn <ge...@googlemail.com> wrote:

> Sebastien, Pete,
>
> I may have misunderstood the base note, however, it looks to me that you
> are
> trying to make changes to the metadata - by adding types - after creating
> a
> data object.
>
> > so we already have in hand a DataObject representing the
> > <component>, containing a list of <property> DataObjects.
> > Now I need to dynamically create a new SDO type containing
>
> If I'm right then this is a known restricion. We have a JIRA (TUSCANY-474)
> that explains it. Bascally, as soon as you create a data object the type
> system is frozen. Pete, is that why you are suggesting creating a
> DataFactory for each componenType?


Exactly! However my brain let me down as when I went to check the code I had
already coded it this way ;-)

What we do need is a way of setting the default value for a type. Maybe you
can enlighten me on what I have to do. Is there code to handle default
values in SDO?

Cheers,

-- 
Pete

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Geoffrey Winn <ge...@googlemail.com>.
Sebastien, Pete,

I may have misunderstood the base note, however, it looks to me that you are
trying to make changes to the metadata - by adding types - after creating a
data object.

> so we already have in hand a DataObject representing the
> <component>, containing a list of <property> DataObjects.
> Now I need to dynamically create a new SDO type containing

If I'm right then this is a known restricion. We have a JIRA (TUSCANY-474)
that explains it. Bascally, as soon as you create a data object the type
system is frozen. Pete, is that why you are suggesting creating a
DataFactory for each componenType?

Geoff.

On 23/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>
> Pete Robbins wrote:
> > Sebastien, I'm fixing this. It shouldn't take long.
> >
> > Cheers,
> >
> >
> > On 22/08/06, Pete Robbins <ro...@googlemail.com> wrote:
> >>
> >> ah!
> >>
> >>  On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
> >>
> >> >
> >> > It doesn't work at all now. With SCDL 0.9 a component declaration
> >> looked
> >> > like that:
> >> > <component>
> >> > <properties>
> >> >      <v:Fred>abc</v:Fred>
> >> >      <v:Joe>xyz</v:Joe>
> >> >     <v:Joe>tuv</v:Joe>
> >> > </properties>
> >> > </component>
> >> >
> >> > The DataObject loaded from that looked exactly like what the client
> >> Cpp
> >> > code expected, allowing you to code
> >> > ComponentContext.getProperties()->getCString("Fred")...
> >> >
> >> > SCDL 0.95 now looks pretty different:
> >> > <component>
> >> >    <property name="Fred">abc</property>
> >> >    <property name="Joe">xyz</property>
> >> >   <property name="Joe">tuv</property>
> >> > </component>
> >> >
> >> > ... missing the convenient <properties> parent element and in a very
> >> > different form now. I'm guessing that we don't want the client code
> to
> >> > change, so we need to massage the DataObject loaded from SCDL to look
> >> > like what the client code wants to see. The other thing is that we
> >> > should use the property types specified in the component type
> >> instead of
> >> > guessing the types from the instance properties in the component
> >> > declaration.
> >> >
> >> > So I'm basically trying to fix ModelLoader to created the expected
> >> > DataObject from what we get from SCDL. In the SupplyChain scenario I
> >> > have multiple Manufacturer and Warehouse components, same
> >> implementation
> >> > but configured with different properties so I need to get this
> >> property
> >> > stuff working...
> >>
> >>
> >>  Ok I understand the problem. I wasn't up to date with the latest
> >> definition of properties. If the current interface to properties is not
> >> workable then we can always feed that back to the spec group. Anyho...
> >>
> >> I think what we need to do is
> >> 1)create a DataFactory for the properties and populate it with the
> types
> >> required for the properties (basic xml types will be there by default
> >> but
> >> any user defined complex types will have to be defined in a schema
> >> somewhere
> >> so lets stick to simple types for now).
> >> 2) When loading the definitions of the properties from the
> componentType
> >> we need to create a new SDO Type for properties associated with this
> >> component and add it to the DataFactory. So we would do something like:
> >>
> >> dataFactory->addType("someNamespace", "componentProperties", ....)
> >> dataFactory->addPropertyToType((<propertyName>, <propType>.... for
> >> each of
> >> the properties defined)
> >>
> >> 3) create a DO of "someNamespace", "componentProperties" type and
> >> save the
> >> DOPtr in the Component defintion in the model
> >> 4) For each property set
> >>  propertyDO->set(<propertyName>, value)
> >> 5) ComponentContext::GetProperties will return the propertyDO from the
> >> Component
> >>
> >> voila!
> >>
> >> So we need to create a datafactory per componentType I think.
> >>
> >> --
> >> Pete
> >>
> >
> >
> >
>
> Cool, Thanks!
>
> --
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Pete Robbins wrote:
> Sebastien, I'm fixing this. It shouldn't take long.
>
> Cheers,
>
>
> On 22/08/06, Pete Robbins <ro...@googlemail.com> wrote:
>>
>> ah!
>>
>>  On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>>
>> >
>> > It doesn't work at all now. With SCDL 0.9 a component declaration 
>> looked
>> > like that:
>> > <component>
>> > <properties>
>> >      <v:Fred>abc</v:Fred>
>> >      <v:Joe>xyz</v:Joe>
>> >     <v:Joe>tuv</v:Joe>
>> > </properties>
>> > </component>
>> >
>> > The DataObject loaded from that looked exactly like what the client 
>> Cpp
>> > code expected, allowing you to code
>> > ComponentContext.getProperties()->getCString("Fred")...
>> >
>> > SCDL 0.95 now looks pretty different:
>> > <component>
>> >    <property name="Fred">abc</property>
>> >    <property name="Joe">xyz</property>
>> >   <property name="Joe">tuv</property>
>> > </component>
>> >
>> > ... missing the convenient <properties> parent element and in a very
>> > different form now. I'm guessing that we don't want the client code to
>> > change, so we need to massage the DataObject loaded from SCDL to look
>> > like what the client code wants to see. The other thing is that we
>> > should use the property types specified in the component type 
>> instead of
>> > guessing the types from the instance properties in the component
>> > declaration.
>> >
>> > So I'm basically trying to fix ModelLoader to created the expected
>> > DataObject from what we get from SCDL. In the SupplyChain scenario I
>> > have multiple Manufacturer and Warehouse components, same 
>> implementation
>> > but configured with different properties so I need to get this 
>> property
>> > stuff working...
>>
>>
>>  Ok I understand the problem. I wasn't up to date with the latest
>> definition of properties. If the current interface to properties is not
>> workable then we can always feed that back to the spec group. Anyho...
>>
>> I think what we need to do is
>> 1)create a DataFactory for the properties and populate it with the types
>> required for the properties (basic xml types will be there by default 
>> but
>> any user defined complex types will have to be defined in a schema 
>> somewhere
>> so lets stick to simple types for now).
>> 2) When loading the definitions of the properties from the componentType
>> we need to create a new SDO Type for properties associated with this
>> component and add it to the DataFactory. So we would do something like:
>>
>> dataFactory->addType("someNamespace", "componentProperties", ....)
>> dataFactory->addPropertyToType((<propertyName>, <propType>.... for 
>> each of
>> the properties defined)
>>
>> 3) create a DO of "someNamespace", "componentProperties" type and 
>> save the
>> DOPtr in the Component defintion in the model
>> 4) For each property set
>>  propertyDO->set(<propertyName>, value)
>> 5) ComponentContext::GetProperties will return the propertyDO from the
>> Component
>>
>> voila!
>>
>> So we need to create a datafactory per componentType I think.
>>
>> -- 
>> Pete
>>
>
>
>

Cool, Thanks!

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Pete Robbins <ro...@googlemail.com>.
Sebastien, I'm fixing this. It shouldn't take long.

Cheers,


On 22/08/06, Pete Robbins <ro...@googlemail.com> wrote:
>
> ah!
>
>  On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>
> >
> > It doesn't work at all now. With SCDL 0.9 a component declaration looked
> > like that:
> > <component>
> > <properties>
> >      <v:Fred>abc</v:Fred>
> >      <v:Joe>xyz</v:Joe>
> >     <v:Joe>tuv</v:Joe>
> > </properties>
> > </component>
> >
> > The DataObject loaded from that looked exactly like what the client Cpp
> > code expected, allowing you to code
> > ComponentContext.getProperties()->getCString("Fred")...
> >
> > SCDL 0.95 now looks pretty different:
> > <component>
> >    <property name="Fred">abc</property>
> >    <property name="Joe">xyz</property>
> >   <property name="Joe">tuv</property>
> > </component>
> >
> > ... missing the convenient <properties> parent element and in a very
> > different form now. I'm guessing that we don't want the client code to
> > change, so we need to massage the DataObject loaded from SCDL to look
> > like what the client code wants to see. The other thing is that we
> > should use the property types specified in the component type instead of
> > guessing the types from the instance properties in the component
> > declaration.
> >
> > So I'm basically trying to fix ModelLoader to created the expected
> > DataObject from what we get from SCDL. In the SupplyChain scenario I
> > have multiple Manufacturer and Warehouse components, same implementation
> > but configured with different properties so I need to get this property
> > stuff working...
>
>
>  Ok I understand the problem. I wasn't up to date with the latest
> definition of properties. If the current interface to properties is not
> workable then we can always feed that back to the spec group. Anyho...
>
> I think what we need to do is
> 1)create a DataFactory for the properties and populate it with the types
> required for the properties (basic xml types will be there by default but
> any user defined complex types will have to be defined in a schema somewhere
> so lets stick to simple types for now).
> 2) When loading the definitions of the properties from the componentType
> we need to create a new SDO Type for properties associated with this
> component and add it to the DataFactory. So we would do something like:
>
> dataFactory->addType("someNamespace", "componentProperties", ....)
> dataFactory->addPropertyToType((<propertyName>, <propType>.... for each of
> the properties defined)
>
> 3) create a DO of "someNamespace", "componentProperties" type and save the
> DOPtr in the Component defintion in the model
> 4) For each property set
>  propertyDO->set(<propertyName>, value)
> 5) ComponentContext::GetProperties will return the propertyDO from the
> Component
>
> voila!
>
> So we need to create a datafactory per componentType I think.
>
> --
> Pete
>



-- 
Pete

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Pete Robbins <ro...@googlemail.com>.
ah!

On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>
>
> It doesn't work at all now. With SCDL 0.9 a component declaration looked
> like that:
> <component>
> <properties>
>      <v:Fred>abc</v:Fred>
>      <v:Joe>xyz</v:Joe>
>     <v:Joe>tuv</v:Joe>
> </properties>
> </component>
>
> The DataObject loaded from that looked exactly like what the client Cpp
> code expected, allowing you to code
> ComponentContext.getProperties()->getCString("Fred")...
>
> SCDL 0.95 now looks pretty different:
> <component>
>    <property name="Fred">abc</property>
>    <property name="Joe">xyz</property>
>   <property name="Joe">tuv</property>
> </component>
>
> ... missing the convenient <properties> parent element and in a very
> different form now. I'm guessing that we don't want the client code to
> change, so we need to massage the DataObject loaded from SCDL to look
> like what the client code wants to see. The other thing is that we
> should use the property types specified in the component type instead of
> guessing the types from the instance properties in the component
> declaration.
>
> So I'm basically trying to fix ModelLoader to created the expected
> DataObject from what we get from SCDL. In the SupplyChain scenario I
> have multiple Manufacturer and Warehouse components, same implementation
> but configured with different properties so I need to get this property
> stuff working...


Ok I understand the problem. I wasn't up to date with the latest definition
of properties. If the current interface to properties is not workable then
we can always feed that back to the spec group. Anyho...

I think what we need to do is
1)create a DataFactory for the properties and populate it with the types
required for the properties (basic xml types will be there by default but
any user defined complex types will have to be defined in a schema somewhere
so lets stick to simple types for now).
2) When loading the definitions of the properties from the componentType we
need to create a new SDO Type for properties associated with this component
and add it to the DataFactory. So we would do something like:

dataFactory->addType("someNamespace", "componentProperties", ....)
dataFactory->addPropertyToType((<propertyName>, <propType>.... for each of
the properties defined)

3) create a DO of "someNamespace", "componentProperties" type and save the
DOPtr in the Component defintion in the model
4) For each property set
 propertyDO->set(<propertyName>, value)
5) ComponentContext::GetProperties will return the propertyDO from the
Component

voila!

So we need to create a datafactory per componentType I think.

-- 
Pete

Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Pete Robbins wrote:
> I thought this worked already in a very basic way!
>
> The code in the runtime/core/test did pretty much what you want I think.
>
>    ComponentContext myContext = ComponentContext::getCurrent();
>
>    DataObjectInstance properties = myContext.getProperties();
>
>    if (properties)
>    {
>        const char* fredVal = properties->getCString("Fred");
>        cout << "Property Fred value: " << fredVal <<endl;
>
>
>        DataObjectList& joeList = properties->getList("Joe");
>        for (int i=0; i<joeList.size();i++)
>        {
>           cout << "Property Joe value " << i << ": " << 
> joeList.getInteger(i)
> <<endl;
>        }
>    }
>
>
>
> Is this what you need or  is there something else? or... does this not 
> work
> at all now?
>
>

It doesn't work at all now. With SCDL 0.9 a component declaration looked 
like that:
<component>
  <properties>
      <v:Fred>abc</v:Fred>
      <v:Joe>xyz</v:Joe>
     <v:Joe>tuv</v:Joe>
  </properties>
</component>

The DataObject loaded from that looked exactly like what the client Cpp 
code expected, allowing you to code 
ComponentContext.getProperties()->getCString("Fred")...

SCDL 0.95 now looks pretty different:
<component>
    <property name="Fred">abc</property>
    <property name="Joe">xyz</property>
   <property name="Joe">tuv</property>
</component>

... missing the convenient <properties> parent element and in a very 
different form now. I'm guessing that we don't want the client code to 
change, so we need to massage the DataObject loaded from SCDL to look 
like what the client code wants to see. The other thing is that we 
should use the property types specified in the component type instead of 
guessing the types from the instance properties in the component 
declaration.

So I'm basically trying to fix ModelLoader to created the expected 
DataObject from what we get from SCDL. In the SupplyChain scenario I 
have multiple Manufacturer and Warehouse components, same implementation 
but configured with different properties so I need to get this property 
stuff working...

>
> Cheers,
>
> On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>>
>> I'd like to get some basic property support in place to be able to
>> configure component properties in the SupplyChain scenario that I'm
>> working on.
>>
>> In an SCDL componentType file I have this for example:
>>    <property name="currency" type="xs:string"/>
>>    <property name="discount" type="xs:double"/>
>> defining property names and types.
>>
>> In my SCDL component declaration I have this:
>> <component ...>
>> <property name="currency"/>USD</property>
>> <property name="discount"/>10</property>
>> </component>
>>
>> In the ModelLoader we are using the SDO runtime to load the <component>
>> SCDL so we already have in hand a DataObject representing the
>> <component>, containing a list of <property> DataObjects.
>> Now I need to dynamically create a new SDO type containing SDO
>> properties for currency and discount (of types string and double), then
>> create a DataObject of that type with its properties set to USD and 10.
>> This DataObject will be returned by ComponentContext.getProperties(),
>> allowing my application code to do the following:
>> DataObject properties=componentContext.getProperties();
>> properties.getCString("currency"); -> returns USD
>> properties.getDouble("discount"); -> returns 10
>>
>> I'm going in circles trying to find the simplest way to dynamically
>> create this new DataObject type. Could one of our SDO experts help me
>> understand how to do this?
>> I accept code too, so if you just give me a magic code snippet showing
>> how to create this SDO type with its SDO properties and move the values
>> into an instance of it, that's even better :)
>>
>> Thanks
>>
>> -- 
>> Jean-Sebastien
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>
>>
>
>


-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: [C++] Creating an SDO DataObject for the properties of a component

Posted by Pete Robbins <ro...@googlemail.com>.
I thought this worked already in a very basic way!

The code in the runtime/core/test did pretty much what you want I think.

    ComponentContext myContext = ComponentContext::getCurrent();

    DataObjectInstance properties = myContext.getProperties();

    if (properties)
    {
        const char* fredVal = properties->getCString("Fred");
        cout << "Property Fred value: " << fredVal <<endl;


        DataObjectList& joeList = properties->getList("Joe");
        for (int i=0; i<joeList.size();i++)
        {
           cout << "Property Joe value " << i << ": " << joeList.getInteger(i)
<<endl;
        }
    }



Is this what you need or  is there something else? or... does this not work
at all now?



Cheers,

On 22/08/06, Jean-Sebastien Delfino <js...@apache.org> wrote:
>
> I'd like to get some basic property support in place to be able to
> configure component properties in the SupplyChain scenario that I'm
> working on.
>
> In an SCDL componentType file I have this for example:
>    <property name="currency" type="xs:string"/>
>    <property name="discount" type="xs:double"/>
> defining property names and types.
>
> In my SCDL component declaration I have this:
> <component ...>
> <property name="currency"/>USD</property>
> <property name="discount"/>10</property>
> </component>
>
> In the ModelLoader we are using the SDO runtime to load the <component>
> SCDL so we already have in hand a DataObject representing the
> <component>, containing a list of <property> DataObjects.
> Now I need to dynamically create a new SDO type containing SDO
> properties for currency and discount (of types string and double), then
> create a DataObject of that type with its properties set to USD and 10.
> This DataObject will be returned by ComponentContext.getProperties(),
> allowing my application code to do the following:
> DataObject properties=componentContext.getProperties();
> properties.getCString("currency"); -> returns USD
> properties.getDouble("discount"); -> returns 10
>
> I'm going in circles trying to find the simplest way to dynamically
> create this new DataObject type. Could one of our SDO experts help me
> understand how to do this?
> I accept code too, so if you just give me a magic code snippet showing
> how to create this SDO type with its SDO properties and move the values
> into an instance of it, that's even better :)
>
> Thanks
>
> --
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>


-- 
Pete