* @param obligatory if the source attribute is obligatory, but value may be <code>null</code>
*/
private DbBooleanMapper(String cdmAttributeString, String dbAttributeString, Boolean defaultValue, Boolean obligatory) {
- super(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
+ super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
}
@Override
* @param obligatory if the source attribute is obligatory, but value may be <code>null</code>
*/
private DbDoiMapper(String cdmAttributeString, String dbAttributeString, String defaultValue, boolean obligatory) {
- super(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
+ super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
}
@Override
}
private DbFixedIntegerMapper(Integer fixInteger, String dbAttributeString) {
- super(null, dbAttributeString, fixInteger, true);
+ super(null, dbAttributeString, fixInteger, true, false);
this.fixInteger = fixInteger;
}
}
private DbFixedStringMapper(String fixString, String dbAttributeString) {
- super(null, dbAttributeString, fixString, true);
+ super(null, dbAttributeString, fixString, true, false);
this.fixString = fixString;
}
}
private DbLastActionMapper(String dbAttributeString, String defaultValue, boolean isActionType) {
- super("updated, created", dbAttributeString, defaultValue, false);
+ super("updated, created", dbAttributeString, defaultValue, false, false);
this.isActionType = isActionType;
}
boolean isCache;
public static DbObjectMapper NewInstance(String cdmAttributeString, String dbAttributeString){
- return new DbObjectMapper(cdmAttributeString, dbAttributeString, null, false);
+ return new DbObjectMapper(cdmAttributeString, dbAttributeString, null, false, false);
}
+ public static DbObjectMapper NewNotNullInstance(String cdmAttributeString, String dbAttributeString){
+ return new DbObjectMapper(cdmAttributeString, dbAttributeString, null, false, true);
+ }
+
public static DbObjectMapper NewInstance(String cdmAttributeString, String dbAttributeString, boolean isCache){
- return new DbObjectMapper(cdmAttributeString, dbAttributeString, null, isCache);
+ return new DbObjectMapper(cdmAttributeString, dbAttributeString, null, isCache, false);
}
- protected DbObjectMapper(String cdmAttributeString, String dbAttributeString, Object defaultValue, boolean isCache) {
+ protected DbObjectMapper(String cdmAttributeString, String dbAttributeString, Object defaultValue, boolean isCache, boolean notNull) {
super(cdmAttributeString, dbAttributeString, defaultValue);
this.isCache = isCache;
}
\r
protected DbExportMapperBase<STATE> exportMapperHelper = new DbExportMapperBase<>();\r
private Integer precision = null;\r
+ //if the source attribute (not the value) is obligatory, currently results in error logging only\r
protected boolean obligatory = true;\r
+ protected boolean notNull = false;\r
\r
protected DbSingleAttributeExportMapperBase(String cdmAttributeString, String dbAttributString, Object defaultValue) {\r
super(cdmAttributeString, dbAttributString, defaultValue);\r
}\r
\r
- protected DbSingleAttributeExportMapperBase(String cdmAttributeString, String dbAttributString, Object defaultValue, boolean obligatory) {\r
- super(cdmAttributeString, dbAttributString, defaultValue);\r
- this.obligatory = obligatory;\r
- }\r
+ /**\r
+ * @param cdmAttributeString source attribute (CDM)\r
+ * @param dbAttributString target attribute (export DB)\r
+ * @param defaultValue default value if source value is <code>null</code>\r
+ * @param obligatory if the source attribute is obligatory, but value may be <code>null</code>\r
+ */\r
+ protected DbSingleAttributeExportMapperBase(String cdmAttributeString, String dbAttributString, Object defaultValue, boolean obligatory, boolean notNull) {\r
+ super(cdmAttributeString, dbAttributString, defaultValue);\r
+ this.notNull = notNull;\r
+ this.obligatory = obligatory;\r
+ }\r
\r
@Override\r
public void initialize(PreparedStatement stmt, IndexCounter index, STATE state, String tableName) {\r
value = defaultValue;\r
}\r
if (value == null){\r
- getPreparedStatement().setNull(getIndex(), sqlType);\r
+ if (notNull){\r
+ logger.error("Value for '"+this.getSourceAttribute()+"' is null but a value is required. Object: " + cdmBase.toString());\r
+ return false;\r
+ }else{\r
+ getPreparedStatement().setNull(getIndex(), sqlType);\r
+ }\r
}else{\r
if (sqlType == Types.INTEGER){\r
try{\r
}
private DbStringMapper(String cdmAttributeString, String dbAttributeString, String defaultValue, boolean obligatory) {
- super(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
+ super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
}
@Override
* @param obligatory if the source attribute is obligatory, but value may be <code>null</code>
*/
private DbTimePeriodMapper(String cdmAttributeString, String dbAttributeString, String defaultValue, boolean obligatory) {
- super(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
+ super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
}
@Override
}
private DbUriMapper(String cdmAttributeString, String dbAttributeString, String defaultValue, boolean obligatory) {
- super(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
+ super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
}
@Override
}
private DbUserMapper(String cdmAttributeString, String dbAttributeString, String defaultValue, boolean obligatory) {
- super(cdmAttributeString, dbAttributeString, defaultValue, obligatory);
+ super(cdmAttributeString, dbAttributeString, defaultValue, obligatory, false);
}
@Override