use of org.finos.waltz.schema.tables.records.MeasurableCategoryRecord in project waltz by khartec.
the class MeasurableHelper method createMeasurableCategory.
public long createMeasurableCategory(String name) {
Set<MeasurableCategory> categories = categoryService.findByExternalId(name);
return CollectionUtilities.maybeFirst(categories).map(c -> c.id().get()).orElseGet(() -> {
long schemeId = ratingSchemeHelper.createEmptyRatingScheme("test");
MeasurableCategoryRecord record = dsl.newRecord(MEASURABLE_CATEGORY);
record.setDescription(name);
record.setName(name);
record.setExternalId(name);
record.setRatingSchemeId(schemeId);
record.setLastUpdatedBy("admin");
record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
record.setEditable(false);
record.store();
return record.getId();
});
}
use of org.finos.waltz.schema.tables.records.MeasurableCategoryRecord in project waltz by khartec.
the class GenericTaxonomyLoader method createCategory.
private Long createCategory(GenericTaxonomyLoadConfig config, DSLContext tx) {
MeasurableCategoryRecord categoryRecord = tx.newRecord(MEASURABLE_CATEGORY);
categoryRecord.setDescription(config.taxonomyDescription());
categoryRecord.setName(config.taxonomyName());
categoryRecord.setExternalId(config.taxonomyExternalId());
categoryRecord.setRatingSchemeId(config.ratingSchemeId());
categoryRecord.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
categoryRecord.setEditable(true);
categoryRecord.setLastUpdatedBy("admin");
categoryRecord.insert();
return categoryRecord.getId();
}
use of org.finos.waltz.schema.tables.records.MeasurableCategoryRecord in project waltz by khartec.
the class WaltzUtilities method getOrCreateMeasurableCategory.
public static Long getOrCreateMeasurableCategory(DSLContext dsl, String externalId, String name) {
Long categoryId = dsl.select(MEASURABLE_CATEGORY.ID).from(MEASURABLE_CATEGORY).where(MEASURABLE_CATEGORY.EXTERNAL_ID.eq(externalId)).fetchOne(MEASURABLE_CATEGORY.ID);
if (categoryId != null) {
return categoryId;
} else {
MeasurableCategoryRecord measurableCategoryRecord = dsl.newRecord(MEASURABLE_CATEGORY);
measurableCategoryRecord.setName(name);
measurableCategoryRecord.setDescription(name);
measurableCategoryRecord.setExternalId(externalId);
measurableCategoryRecord.setRatingSchemeId(1L);
measurableCategoryRecord.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
measurableCategoryRecord.setLastUpdatedBy("admin");
measurableCategoryRecord.store();
return measurableCategoryRecord.getId();
}
}
use of org.finos.waltz.schema.tables.records.MeasurableCategoryRecord in project waltz by khartec.
the class HigherEducationTaxonomyImport method getOrCreateCategoryId.
private long getOrCreateCategoryId(DSLContext tx) {
log("Attempting to find category id using external id: %s", CATEGORY_EXTERNAL_ID);
return tx.select(MEASURABLE_CATEGORY.ID).from(MEASURABLE_CATEGORY).where(MEASURABLE_CATEGORY.EXTERNAL_ID.eq(CATEGORY_EXTERNAL_ID)).fetchOptional(MEASURABLE_CATEGORY.ID).orElseGet(() -> {
log("Could not find an existing category, therefore creating a new one");
MeasurableCategoryRecord record = tx.newRecord(MEASURABLE_CATEGORY);
record.setName("UK Higher Education Capabilities");
record.setDescription("UK Higher Education Capabilities sourced from UCISA");
record.setEditable(false);
record.setLastUpdatedBy("admin");
record.setRatingSchemeId(1L);
record.setExternalId(CATEGORY_EXTERNAL_ID);
log("Storing the new category and getting returning it's Waltz id");
record.store();
return record.getId();
});
}
Aggregations