static boolean generateSqlColumnDefaultConstraint(Attribute attr) { return attr.getDefaultValue() != null && !EntityTypeUtils.isMultipleReferenceType(attr); }
private static String getSqlDefaulValue(Attribute attribute) { return getSqlDefaulValue(attribute, attribute.getDefaultValue()); }
private EntityType cutDefaultValues(EntityType copy, CopyState state) { stream(copy.getAtomicAttributes()) .filter(EntityTypeUtils::isReferenceType) .filter(Attribute::hasDefaultValue) .forEach( attr -> { state.referenceDefaultValues().put(attr.getIdentifier(), attr.getDefaultValue()); attr.setDefaultValue(null); }); return copy; }
this.defaultValue = attr.getDefaultValue(); } else this.defaultValue = null;
/** * Add attribute to entityType. * * @param entityType the {@link EntityType} to add attribute to * @param attr attribute to add */ private void addAttributeInternal(EntityType entityType, Attribute attr) { if (!isPersisted(attr)) { return; } if (isMultipleReferenceType(attr)) { createJunctionTable(entityType, attr); if (attr.getDefaultValue() != null && !attr.isNillable()) { @SuppressWarnings("unchecked") Iterable<Entity> defaultRefEntities = (Iterable<Entity>) AttributeUtils.getDefaultTypedValue(attr); if (!Iterables.isEmpty(defaultRefEntities)) { createJunctionTableRows(entityType, attr, defaultRefEntities); } } } else { createColumn(entityType, attr); } }
Entity getDefaultSettings() { Entity defaultSettingsEntity = new DynamicEntity(this); for (Attribute attr : this.getAtomicAttributes()) { // default values are stored/retrieved as strings, so we convert them to the required type // here. String defaultValue = attr.getDefaultValue(); if (defaultValue != null) { Object typedDefaultValue = getTypedValue(defaultValue, attr, entityManager); defaultSettingsEntity.set(attr.getName(), typedDefaultValue); } } defaultSettingsEntity.set(ATTR_ID, getSettingsEntityId()); return defaultSettingsEntity; }
void validateDefaultValue(Attribute attr, boolean validateEntityReferences) { String value = attr.getDefaultValue(); if (value != null) { if (attr.isUnique()) {
this.nillable = attr.isNillable(); this.readOnly = attr.isReadOnly(); this.defaultValue = attr.getDefaultValue(); this.labelAttribute = attr.equals(entityType.getLabelAttribute()); this.unique = attr.isUnique();
String visibleExpression = attribute.getVisibleExpression(); String validationExpression = attribute.getValidationExpression(); String defaultValue = attribute.getDefaultValue(); Integer sequenceNumber = attribute.getSequenceNumber() != null ? attribute.getSequenceNumber() : 0;