[MOBY-dev] Datatype instantiation in jMoby
Ola Spjuth
ola.spjuth at farmbio.uu.se
Mon Oct 15 16:19:39 UTC 2007
Hi,
In jMoby, I look up a service, and get the first primaryInputs
DataType by
service.getPrimaryData()[0].getDataType();
This gives me a Datatype with correct name and LSID, but nothing more
(no children).
If I do the following:
String dataTypeName=service.getPrimaryInputs()[i].getDataType
().getName();
primaryData[i] = new MobyDataComposite(dataTypeName);
MobyDataType dataType=primaryData[i].getDataType();
Then jMoby reads the ontology and I get a dataType that has relations
(children). How can I achieve this without having to instantiate a
bogus MobyDataComposite? What is the purpose of this behaviour? Would
something like this be an acceptable API-request:
service.getPrimaryData()[0].getDataType();
service.getPrimaryData()[0].populateFromOntology();
Next question:
I'd like to create MobyDataObjects that I can later populate with
values.
The line
MobyDataObject obj = MobyDataObject.createInstanceFromString
(childTypeName,"0");
works fine, but I'd like to do is create an object with no values,
like the following:
for(MobyRelationship child: dataType.getAllChildren()){
String childName = child.getName();
String childTypeName = child.getDataTypeName();
if(PrimitiveTypes.isPrimitive(childTypeName)){
MobyDataObject obj = new MobyDataObject(childTypeName);
primaryComposites[i].put(childName,obj);
}
}
Is it wrong to instantiate the values first and fill them at a later
point?
Last question:
Can a service take only one primitive DataType as primaryInput or
does it always require a MobyDataComposite? Is it an error in that
case to supply a MobyDataComposite with only one primitive
MobyDataObject in it (i.e. is it OK to always send a
MobyDataComposite as PrimaryInput to a service)?
Thanks,
.../Ola
More information about the MOBY-dev
mailing list