use of org.jumpmind.pos.persist.model.AugmenterConfig in project openpos-framework by JumpMind.
the class DatabaseSchema method createAugmentedFieldsMetaData.
private static void createAugmentedFieldsMetaData(ModelClassMetaData meta, List<Column> columns, IDatabasePlatform databasePlatform, AugmenterHelper augmenterHelper) {
if (augmenterHelper != null) {
List<AugmenterConfig> configs = augmenterHelper.getAugmenterConfigs(meta.getClazz());
for (AugmenterConfig config : configs) {
meta.getAugmenterConfigs().add(config);
for (AugmenterModel augmenterModel : config.getAugmenters()) {
meta.getAugmentedFieldNames().add(augmenterModel.getName());
Column column = new Column();
column.setName(alterCaseToMatchDatabaseDefaultCase(config.getPrefix(), databasePlatform) + alterCaseToMatchDatabaseDefaultCase(camelToSnakeCase(augmenterModel.getName()), databasePlatform));
column.setDefaultValue(augmenterModel.getDefaultValue());
column.setSize(augmenterModel.getSize() != null ? Integer.toString(augmenterModel.getSize()) : "32");
column.setTypeCode(Types.VARCHAR);
columns.add(column);
}
}
}
}
use of org.jumpmind.pos.persist.model.AugmenterConfig in project openpos-framework by JumpMind.
the class ModelValidator method checkAugmentedFields.
protected static void checkAugmentedFields(ModelClassMetaData meta) {
if (CollectionUtils.size(meta.getAugmenterConfigs()) > 1) {
Map<String, Integer> augmenterNameCounts = new HashMap<>();
for (AugmenterConfig config : meta.getAugmenterConfigs()) {
for (String name : config.getAugmenterNames()) {
Integer count = augmenterNameCounts.get(name);
if (count == null) {
count = 1;
} else {
count++;
}
augmenterNameCounts.put(name, count);
}
}
for (Map.Entry<String, Integer> entry : augmenterNameCounts.entrySet()) {
if (entry.getValue() > 1) {
throw new PersistException("Duplicate augmenter name " + entry.getKey() + " found on model " + meta.getClazz());
}
}
}
}
use of org.jumpmind.pos.persist.model.AugmenterConfig in project openpos-framework by JumpMind.
the class DatabaseSchema method getAugmentedColumnsToFields.
private Map<String, String> getAugmentedColumnsToFields(Class<?> entityClass) {
Map<String, String> columnsToAugmentedFields = new CaseInsensitiveMap<>();
List<AugmenterConfig> configs = augmenterHelper.getAugmenterConfigs(entityClass);
for (AugmenterConfig config : configs) {
for (String augmenterName : config.getAugmenterNames()) {
columnsToAugmentedFields.put(config.getPrefix() + camelToSnakeCase(augmenterName), augmenterName);
}
}
return columnsToAugmentedFields;
}
Aggregations