You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2006/10/01 18:56:16 UTC
svn commit: r451767 - in /incubator/ofbiz/trunk/framework/entity:
dtd/entitymodel.xsd src/org/ofbiz/entity/model/ModelViewEntity.java
Author: jonesde
Date: Sun Oct 1 09:56:16 2006
New Revision: 451767
URL: http://svn.apache.org/viewvc?view=rev&rev=451767
Log:
Applied patch from Leon Torres, with small change, to implement new default value feature for complex aliases in view entities; Apache Jira #OFBIZ-336
Modified:
incubator/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd
incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
Modified: incubator/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd?view=diff&rev=451767&r1=451766&r2=451767
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd (original)
+++ incubator/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd Sun Oct 1 09:56:16 2006
@@ -333,6 +333,7 @@
<xs:attributeGroup name="attlist.complex-alias-field">
<xs:attribute type="xs:string" name="entity-alias" use="required"/>
<xs:attribute type="xs:string" name="field" use="required"/>
+ <xs:attribute type="xs:string" name="default-value"/>
<xs:attribute name="function">
<xs:simpleType>
<xs:restriction base="xs:token">
Modified: incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?view=diff&rev=451767&r1=451766&r2=451767
==============================================================================
--- incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original)
+++ incubator/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Sun Oct 1 09:56:16 2006
@@ -857,31 +857,29 @@
public static class ComplexAliasField implements ComplexAliasMember {
protected String entityAlias = "";
protected String field = "";
+ protected String defaultValue = null;
protected String function = null;
- public ComplexAliasField(String entityAlias , String field) {
- this.entityAlias = entityAlias;
- this.field = field;
- }
-
- public ComplexAliasField(String entityAlias , String field, String function) {
- this.entityAlias = entityAlias;
- this.field = field;
- this.function = function;
- }
-
public ComplexAliasField(Element complexAliasFieldElement) {
this.entityAlias = complexAliasFieldElement.getAttribute("entity-alias");
this.field = complexAliasFieldElement.getAttribute("field");
+ this.defaultValue = complexAliasFieldElement.getAttribute("default-value");
this.function = complexAliasFieldElement.getAttribute("function");
}
+ /**
+ * Make the alias as follows: function(coalesce(entityAlias.field, defaultValue))
+ */
public void makeAliasColName(StringBuffer colNameBuffer, StringBuffer fieldTypeBuffer, ModelViewEntity modelViewEntity, ModelReader modelReader) {
ModelEntity modelEntity = modelViewEntity.getAliasedEntity(entityAlias, modelReader);
ModelField modelField = modelViewEntity.getAliasedField(modelEntity, field, modelReader);
String colName = entityAlias + "." + modelField.getColName();
+ if (UtilValidate.isNotEmpty(defaultValue)) {
+ colName = "COALESCE(" + colName + "," + defaultValue + ")";
+ }
+
if (UtilValidate.isNotEmpty(function)) {
String prefix = (String) functionPrefixMap.get(function);
if (prefix == null) {