Extending Data Warehouse - is createOneTimeRecord() needed
When reviewing the sample code in https://jazz.net/wiki/bin/view/Main/DataWarehouseExtending, I noticed that the following code (for creating a fact table) sets up a reference between the TIME_ID column and the identifier in the Time Dimension table:
Then, later on in the article, the following sample code is provided for updating the fact table created by the above code:
QUESTIONS
Doesn't the above sample code have to create a record in the Time Dimension?
Is that done by adding the following calling?
Thanks.
private void createNumbersStorageFact() {
IFieldDescriptor id = createFieldDescriptor(
ISnapshotService.FACT_ID_COLUMN, FieldKind.LONG,
FieldFlags.DEFAULT);
IFieldDescriptor timeId = createFieldDescriptor(
ISnapshotService.TIME_ID_COLUMN, FieldKind.LONG,
FieldFlags.QUERYABLE);
IFieldDescriptor continent = createFieldDescriptor(
INumbersSnapshotService.CONTINENT_COLUMN,
FieldKind.STRING, FieldFlags.QUERYABLE | FieldFlags.PARAMETER);
IFieldDescriptor number = createFieldDescriptor(
INumbersSnapshotService.NUMBER_COLUMN,
FieldKind.INTEGER, FieldFlags.DEFAULT);
timeId.setReference(getTableDescriptor(
ICommonSnapshotService.SNAPSHOT_NAME,
ICommonSnapshotService.TIME_DIMENSION));
continent.setAggregationKind(AggregationKind.SELECT);
number.setAggregationKind(AggregationKind.SELECT);
createTableDescriptor(
INumbersSnapshotService.NUMBERS_FACT_TABLE,
new IFieldDescriptor[] { id, timeId, continent, number },
id);
}
Then, later on in the article, the following sample code is provided for updating the fact table created by the above code:
protected void updateSnapshot() throws TeamRepositoryException {
String[] continents = { "North America", "South America", "Europe",
"Asia", "Africa", "Australia", "Antarctica" };
long time = System.currentTimeMillis();
long nextFactId = getNextFactId(getTableDescriptor(NUMBERS_FACT_TABLE));
Random random = new Random();
for (int i = 0; i < continents.length; i++) {
ITableDescriptor table = getTableDescriptor(NUMBERS_FACT_TABLE);
IWritableDataRow record = createTableRecord(table);
record.setLong(FACT_ID_COLUMN, nextFactId);
record.setLong(TIME_ID_COLUMN, time);
record.setString(CONTINENT_COLUMN, continents[i]);
record.setInt(NUMBER_COLUMN, random.nextInt());
storeTableRecord(table, record);
nextFactId++;
}
}
Doesn't the above sample code have to create a record in the Time Dimension?
Is that done by adding the following calling?
getCommonSnapshotService().createOneTimeRecord(time);
Thanks.