use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method addSpecialColumns.
private void addSpecialColumns(BeModelElement modelElements, DynamicPropertySet dps, List<String> specialColumns) {
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
Timestamp currentTime = new Timestamp(new Date().getTime());
for (String propertyName : specialColumns) {
ColumnDef columnDef = columns.get(propertyName);
if (columnDef != null) {
Object value = getSpecialColumnsValue(propertyName, currentTime);
if (dps.getProperty(propertyName) == null) {
DynamicProperty newProperty = new DynamicProperty(propertyName, value.getClass(), value);
newProperty.setHidden(true);
dps.add(newProperty);
} else {
dps.setValue(propertyName, value);
}
}
}
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method addDynamicProperties.
public <T extends DynamicPropertySet> T addDynamicProperties(T dps, BeModelElement modelElements, Collection<String> propertyNames) {
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
for (String propertyName : propertyNames) {
ColumnDef columnDef = columns.get(propertyName);
DynamicProperty dynamicProperty = getDynamicPropertyWithoutTags(columnDef, modelElements);
addTags(dynamicProperty, columnDef);
dps.add(dynamicProperty);
}
return dps;
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method addDpsExcludedColumnsWithoutTags.
public <T extends DynamicPropertySet> T addDpsExcludedColumnsWithoutTags(T dps, BeModelElement modelElements, Collection<String> excludedColumns) {
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
ArrayList<String> excludedColumnsList = new ArrayList<>(excludedColumns);
for (Map.Entry<String, ColumnDef> entry : columns.entrySet()) {
if (!excludedColumnsList.contains(entry.getKey())) {
DynamicProperty dynamicProperty = getDynamicPropertyWithoutTags(entry.getValue(), modelElements);
dps.add(dynamicProperty);
}
excludedColumnsList.remove(entry.getKey());
}
for (String propertyName : excludedColumnsList) {
log.warning("Column " + propertyName + " not found in " + modelElements.getName());
}
return dps;
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method checkDpsColumns.
public void checkDpsColumns(BeModelElement modelElements, DynamicPropertySet dps) {
StringBuilder errorMsg = new StringBuilder();
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
for (ColumnDef column : columns.values()) {
if (!column.isCanBeNull() && !column.isAutoIncrement() && column.getDefaultValue() == null && !dps.hasProperty(column.getName())) {
errorMsg.append("Dps not contain notNull column '").append(column.getName()).append("'\n");
}
}
for (DynamicProperty property : dps) {
if (!columns.keySet().contains(property.getName())) {
errorMsg.append("Entity not contain column '").append(property.getName()).append("'\n");
}
}
if (!errorMsg.toString().isEmpty()) {
throw Be5Exception.internal("Dps columns errors for modelElements '" + modelElements.getName() + "'\n" + errorMsg);
}
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method addDpForColumnsWithoutTags.
public <T extends DynamicPropertySet> T addDpForColumnsWithoutTags(T dps, BeModelElement modelElements, Collection<String> columnNames) {
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
for (String propertyName : columnNames) {
ColumnDef columnDef = columns.get(propertyName);
if (columnDef != null) {
DynamicProperty dynamicProperty = getDynamicPropertyWithoutTags(columnDef, modelElements);
dps.add(dynamicProperty);
} else {
throw Be5Exception.internal("Entity '" + modelElements.getName() + "' not contain column " + propertyName);
}
}
return dps;
}
Aggregations