It's all about the answers!

Ask a question

Extending Data Warehouse - is createOneTimeRecord() needed


Samit Mehta (31103) | asked Sep 15 '08, 12:07 p.m.
JAZZ DEVELOPER
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:

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++;
}
}


QUESTIONS
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.

One answer



permanent link
Rafik Jaouani (5.0k16) | answered Sep 18 '08, 10:17 a.m.
JAZZ DEVELOPER
Good catch Samit. You are correct. A row must be inserted in the TIME table for the join to that table to work. I will fix the Wiki and the example.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.