Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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:

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.

0 votes



One answer

Permanent link
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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Sep 15 '08, 12:07 p.m.

Question was seen: 6,860 times

Last updated: Sep 15 '08, 12:07 p.m.

Confirmation Cancel Confirm