You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/05/04 17:58:35 UTC
[3/5] syncope git commit: [SYNCOPE-664] Hiding Oracle behavior in
AbstractAttrValue#getStringValue
[SYNCOPE-664] Hiding Oracle behavior in AbstractAttrValue#getStringValue
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b81cea71
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b81cea71
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b81cea71
Branch: refs/heads/1_2_X
Commit: b81cea711945ea7e5133371d9f06c42c398650b2
Parents: b97eb56
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon May 4 17:50:01 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon May 4 17:50:01 2015 +0200
----------------------------------------------------------------------
.../persistence/beans/AbstractAttrValue.java | 46 ++++++++++++--------
core/src/test/resources/content.xml | 4 +-
2 files changed, 32 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/b81cea71/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java b/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
index 6ee527e..d88fba0 100644
--- a/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
+++ b/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
@@ -28,6 +28,7 @@ import javax.persistence.TemporalType;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.syncope.common.SyncopeConstants;
@@ -105,7 +106,15 @@ public abstract class AbstractAttrValue extends AbstractBaseBean {
}
public String getStringValue() {
- return stringValue;
+ // workaround for Oracle DB considering empty string values as NULL (SYNCOPE-664)
+ return dateValue == null
+ && booleanValue == null
+ && longValue == null
+ && doubleValue == null
+ && binaryValue == null
+ && stringValue == null
+ ? StringUtils.EMPTY
+ : stringValue;
}
public void setStringValue(final String stringValue) {
@@ -195,21 +204,21 @@ public abstract class AbstractAttrValue extends AbstractBaseBean {
return (T) (booleanValue != null
? getBooleanValue()
: dateValue != null
- ? getDateValue()
- : doubleValue != null
- ? getDoubleValue()
- : longValue != null
- ? getLongValue()
- : binaryValue != null
- ? getBinaryValue()
- : stringValue);
+ ? getDateValue()
+ : doubleValue != null
+ ? getDoubleValue()
+ : longValue != null
+ ? getLongValue()
+ : binaryValue != null
+ ? getBinaryValue()
+ : getStringValue());
}
public String getValueAsString() {
final AttributeSchemaType type = getAttribute() == null || getAttribute().getSchema() == null
|| getAttribute().getSchema().getType() == null
- ? AttributeSchemaType.String
- : getAttribute().getSchema().getType();
+ ? AttributeSchemaType.String
+ : getAttribute().getSchema().getType();
return getValueAsString(type);
}
@@ -228,22 +237,25 @@ public abstract class AbstractAttrValue extends AbstractBaseBean {
case Long:
result = getAttribute() == null || getAttribute().getSchema() == null
|| getAttribute().getSchema().getConversionPattern() == null
- ? getLongValue().toString()
- : DataFormat.format(getLongValue(), getAttribute().getSchema().getConversionPattern());
+ ? getLongValue().toString()
+ : DataFormat.format(getLongValue(),
+ getAttribute().getSchema().getConversionPattern());
break;
case Double:
result = getAttribute() == null || getAttribute().getSchema() == null
|| getAttribute().getSchema().getConversionPattern() == null
- ? getDoubleValue().toString()
- : DataFormat.format(getDoubleValue(), getAttribute().getSchema().getConversionPattern());
+ ? getDoubleValue().toString()
+ : DataFormat.format(getDoubleValue(),
+ getAttribute().getSchema().getConversionPattern());
break;
case Date:
result = getAttribute() == null || getAttribute().getSchema() == null
|| getAttribute().getSchema().getConversionPattern() == null
- ? DataFormat.format(getDateValue())
- : DataFormat.format(getDateValue(), false, getAttribute().getSchema().getConversionPattern());
+ ? DataFormat.format(getDateValue())
+ : DataFormat.format(getDateValue(), false, getAttribute().getSchema().
+ getConversionPattern());
break;
case Binary:
http://git-wip-us.apache.org/repos/asf/syncope/blob/b81cea71/core/src/test/resources/content.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/content.xml b/core/src/test/resources/content.xml
index 94e7ed2..a361a6d 100644
--- a/core/src/test/resources/content.xml
+++ b/core/src/test/resources/content.xml
@@ -33,7 +33,9 @@ under the License.
+ provided as non-empty string: NotificationJob runs according to the given value -->
<CSchema name="notificationjob.cronExpression" type="String"
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"/>
-
+ <CAttr id="2" owner_id="1" schema_name="notificationjob.cronExpression"/>
+ <CAttrValue id="2" attribute_id="2" stringValue=""/>
+
<CSchema name="notification.maxRetries" type="Long"
mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
<CAttr id="3" owner_id="1" schema_name="notification.maxRetries"/>