Download Diffusion 5.1 User Guide - Documentation

Transcript
// Create metadata for the topic
final MContent metadata = defineMetadata();
// Get a topic builder
final RecordTopicDetails.Builder builder =
tc.newDetailsBuilder(RecordTopicDetails.Builder.class);
// Create the topic with metadata
tc.addTopic(
TOPIC_NAME,
builder.metadata(metadata).build(),
new TopicControl.AddCallback.Default() {
@Override
public void onTopicAdded(String topic) {
theTopic = topic;
}
});
}
/**
* A simple example of creating content metadata with two
records.
*
* @return content metadata
*/
public MContent defineMetadata() {
return factory.content(
"Content",
createNameAndAddressRecord(),
createMultipleRateCurrencyRecord("Exchange Rates",
5));
}
/**
* Creates a simple name and address record with fixed
name single
* multiplicity fields.
*
* @return record definition.
*/
public MRecord createNameAndAddressRecord() {
return factory.record(
"NameAndAddress",
factory.string("FirstName"),
factory.string("Surname"),
factory.string("HouseNumber"),
factory.string("Street"),
factory.string("Town"),
factory.string("State"),
factory.string("PostCode"));
}
/**
* This creates a record with two fields, a string called
"Currency" and a
* decimal string called "Rate" with a default value of
1.00 which repeats a
* specified number of times.
*
* @param name the record name
* @param occurs the number of occurrences of the "Rate"
field
* @return the metadata record
Diffusion | 252