You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2009/08/14 01:33:40 UTC
svn commit: r804060 [7/7] - in /ofbiz/branches/executioncontext20090812:
applications/accounting/src/org/ofbiz/accounting/payment/
applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/
applications/order/src/org/ofbiz/order/finaccount/ app...
Added: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java?rev=804060&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java (added)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java Thu Aug 13 23:33:38 2009
@@ -0,0 +1,283 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.entity.model;
+
+import java.util.*;
+import org.w3c.dom.*;
+
+import org.ofbiz.entity.jdbc.*;
+import org.ofbiz.base.util.*;
+
+/**
+ * Generic Entity - Field model class
+ *
+ */
+@SuppressWarnings("serial")
+public class ModelFieldImpl extends ModelChild implements ModelField {
+
+ /** The name of the Field */
+ protected String name = "";
+
+ /** The type of the Field */
+ protected String type = "";
+
+ /** The col-name of the Field */
+ protected String colName = "";
+
+ /** boolean which specifies whether or not the Field is a Primary Key */
+ protected boolean isPk = false;
+ protected boolean encrypt = false;
+ protected boolean isNotNull = false;
+ protected boolean isAutoCreatedInternal = false;
+ protected boolean enableAuditLog = false;
+
+ /** validators to be called when an update is done */
+ protected List<String> validators = new ArrayList<String>();
+
+ /** Default Constructor */
+ public ModelFieldImpl() {}
+
+ /** Fields Constructor */
+ public ModelFieldImpl(String name, String type, String colName, boolean isPk) {
+ this(name, type, colName, isPk, false, false);
+ }
+
+ public ModelFieldImpl(String name, String type, String colName, boolean isPk, boolean encrypt, boolean enableAuditLog) {
+ this.name = name;
+ this.type = type;
+ this.setColName(colName);
+ this.isPk = isPk;
+ this.encrypt = encrypt;
+ this.enableAuditLog = enableAuditLog;
+ }
+
+ /** XML Constructor */
+ public ModelFieldImpl(Element fieldElement) {
+ this.type = UtilXml.checkEmpty(fieldElement.getAttribute("type")).intern();
+ this.name = UtilXml.checkEmpty(fieldElement.getAttribute("name")).intern();
+ this.setColName(UtilXml.checkEmpty(fieldElement.getAttribute("col-name")).intern());
+ this.isPk = false; // is set elsewhere
+ this.encrypt = UtilXml.checkBoolean(fieldElement.getAttribute("encrypt"), false);
+ this.description = UtilXml.childElementValue(fieldElement, "description");
+ this.enableAuditLog = UtilXml.checkBoolean(fieldElement.getAttribute("enable-audit-log"), false);
+ this.isNotNull = UtilXml.checkBoolean(fieldElement.getAttribute("not-null"), false);
+
+ NodeList validateList = fieldElement.getElementsByTagName("validate");
+
+ for (int i = 0; i < validateList.getLength(); i++) {
+ Element element = (Element) validateList.item(i);
+
+ this.validators.add(UtilXml.checkEmpty(element.getAttribute("name")).intern());
+ }
+ }
+
+ /** DB Names Constructor */
+ public ModelFieldImpl(DatabaseUtil.ColumnCheckInfo ccInfo, ModelFieldTypeReader modelFieldTypeReader) {
+ this.colName = ccInfo.columnName;
+ this.name = ModelUtil.dbNameToVarName(this.colName);
+
+ // figure out the type according to the typeName, columnSize and decimalDigits
+ this.type = ModelUtil.induceFieldType(ccInfo.typeName, ccInfo.columnSize, ccInfo.decimalDigits, modelFieldTypeReader);
+
+ this.isPk = ccInfo.isPk;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getName()
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getType()
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setType(java.lang.String)
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getColName()
+ */
+ public String getColName() {
+ return this.colName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setColName(java.lang.String)
+ */
+ public void setColName(String colName) {
+ this.colName = colName;
+ if (this.colName == null || this.colName.length() == 0) {
+ this.colName = ModelUtil.javaNameToDbName(UtilXml.checkEmpty(this.name));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getIsPk()
+ */
+ public boolean getIsPk() {
+ return this.isPk;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setIsPk(boolean)
+ */
+ public void setIsPk(boolean isPk) {
+ this.isPk = isPk;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getIsNotNull()
+ */
+ public boolean getIsNotNull() {
+ return this.isNotNull;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setIsNotNull(boolean)
+ */
+ public void setIsNotNull(boolean isNotNull) {
+ this.isNotNull = isNotNull;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getEncrypt()
+ */
+ public boolean getEncrypt() {
+ return this.encrypt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setEncrypt(boolean)
+ */
+ public void setEncrypt(boolean encrypt) {
+ this.encrypt = encrypt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getEnableAuditLog()
+ */
+ public boolean getEnableAuditLog() {
+ return this.enableAuditLog;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getIsAutoCreatedInternal()
+ */
+ public boolean getIsAutoCreatedInternal() {
+ return this.isAutoCreatedInternal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#setIsAutoCreatedInternal(boolean)
+ */
+ public void setIsAutoCreatedInternal(boolean isAutoCreatedInternal) {
+ this.isAutoCreatedInternal = isAutoCreatedInternal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getValidator(int)
+ */
+ public String getValidator(int index) {
+ return this.validators.get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#getValidatorsSize()
+ */
+ public int getValidatorsSize() {
+ return this.validators.size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#addValidator(java.lang.String)
+ */
+ public void addValidator(String validator) {
+ this.validators.add(validator);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#removeValidator(int)
+ */
+ public String removeValidator(int index) {
+ return this.validators.remove(index);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() != getClass()) return false;
+ ModelField other = (ModelField) obj;
+ return other.getName().equals(getName()) && other.getModelEntity() == getModelEntity();
+ }
+
+ @Override
+ public int hashCode() {
+ return getModelEntity().hashCode() ^ getName().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return getModelEntity() + "@" + getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ofbiz.entity.model.ModelField#toXmlElement(org.w3c.dom.Document)
+ */
+ public Element toXmlElement(Document document) {
+ Element root = document.createElement("field");
+ root.setAttribute("name", this.getName());
+ if (!this.getColName().equals(ModelUtil.javaNameToDbName(this.getName()))) {
+ root.setAttribute("col-name", this.getColName());
+ }
+ root.setAttribute("type", this.getType());
+ if (this.getEncrypt()) {
+ root.setAttribute("encrypt", "true");
+ }
+ if (this.getIsNotNull()) {
+ root.setAttribute("not-null", "true");
+ }
+
+ Iterator<String> valIter = this.validators.iterator();
+ if (valIter != null) {
+ while (valIter.hasNext()) {
+ String validator = valIter.next();
+ Element val = document.createElement("validate");
+ val.setAttribute("name", validator);
+ root.appendChild(val);
+ }
+ }
+
+ return root;
+ }
+}
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelFieldImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java Thu Aug 13 23:33:38 2009
@@ -18,98 +18,24 @@
*******************************************************************************/
package org.ofbiz.entity.model;
-import java.util.List;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilXml;
-
-
/**
* Generic Entity - KeyMap model class
*
*/
-public class ModelKeyMap implements java.io.Serializable {
+public interface ModelKeyMap {
/** name of the field in this entity */
- protected String fieldName = "";
-
- /** name of the field in related entity */
- protected String relFieldName = "";
+ public String getFieldName();
- /** Default Constructor */
- public ModelKeyMap() {}
-
- /** Data Constructor, if relFieldName is null defaults to fieldName */
- public ModelKeyMap(String fieldName, String relFieldName) {
- this.fieldName = fieldName;
- this.relFieldName = UtilXml.checkEmpty(relFieldName, this.fieldName);
- }
-
- /** XML Constructor */
- public ModelKeyMap(Element keyMapElement) {
- this.fieldName = UtilXml.checkEmpty(keyMapElement.getAttribute("field-name")).intern();
- // if no relFieldName is specified, use the fieldName; this is convenient for when they are named the same, which is often the case
- this.relFieldName = UtilXml.checkEmpty(keyMapElement.getAttribute("rel-field-name"), this.fieldName).intern();
- }
-
- /** name of the field in this entity */
- public String getFieldName() {
- return this.fieldName;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
+ public void setFieldName(String fieldName);
/** name of the field in related entity */
- public String getRelFieldName() {
- return this.relFieldName;
- }
-
- public void setRelFieldName(String relFieldName) {
- this.relFieldName = relFieldName;
- }
-
- // ======= Some Convenience Oriented Factory Methods =======
- public static List<ModelKeyMap> makeKeyMapList(String fieldName1) {
- return UtilMisc.toList(new ModelKeyMap(fieldName1, null));
- }
- public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1) {
- return UtilMisc.toList(new ModelKeyMap(fieldName1, relFieldName1));
- }
- public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2) {
- return UtilMisc.toList(new ModelKeyMap(fieldName1, relFieldName1), new ModelKeyMap(fieldName2, relFieldName2));
- }
- public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2, String fieldName3, String relFieldName3) {
- return UtilMisc.toList(new ModelKeyMap(fieldName1, relFieldName1), new ModelKeyMap(fieldName2, relFieldName2), new ModelKeyMap(fieldName3, relFieldName3));
- }
-
- @Override
- public int hashCode() {
- return this.fieldName.hashCode() + this.relFieldName.hashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof ModelKeyMap)) return false;
- ModelKeyMap otherKeyMap = (ModelKeyMap) other;
-
- if (!otherKeyMap.fieldName.equals(this.fieldName)) return false;
- if (!otherKeyMap.relFieldName.equals(this.relFieldName)) return false;
-
- return true;
- }
-
- public Element toXmlElement(Document document) {
- Element root = document.createElement("key-map");
- root.setAttribute("field-name", this.getFieldName());
- if (!this.getFieldName().equals(this.getRelFieldName())) {
- root.setAttribute("rel-field-name", this.getRelFieldName());
- }
+ public String getRelFieldName();
+
+ public void setRelFieldName(String relFieldName);
- return root;
- }
+ public Element toXmlElement(Document document);
}
Added: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java?rev=804060&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java (added)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java Thu Aug 13 23:33:38 2009
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.entity.model;
+
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilXml;
+
+
+/**
+ * Generic Entity - KeyMap model class
+ *
+ */
+public class ModelKeyMapImpl implements java.io.Serializable, ModelKeyMap {
+
+ /** name of the field in this entity */
+ protected String fieldName = "";
+
+ /** name of the field in related entity */
+ protected String relFieldName = "";
+
+ /** Default Constructor */
+ public ModelKeyMapImpl() {}
+
+ /** Data Constructor, if relFieldName is null defaults to fieldName */
+ public ModelKeyMapImpl(String fieldName, String relFieldName) {
+ this.fieldName = fieldName;
+ this.relFieldName = UtilXml.checkEmpty(relFieldName, this.fieldName);
+ }
+
+ /** XML Constructor */
+ public ModelKeyMapImpl(Element keyMapElement) {
+ this.fieldName = UtilXml.checkEmpty(keyMapElement.getAttribute("field-name")).intern();
+ // if no relFieldName is specified, use the fieldName; this is convenient for when they are named the same, which is often the case
+ this.relFieldName = UtilXml.checkEmpty(keyMapElement.getAttribute("rel-field-name"), this.fieldName).intern();
+ }
+
+ /** name of the field in this entity */
+ public String getFieldName() {
+ return this.fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ /** name of the field in related entity */
+ public String getRelFieldName() {
+ return this.relFieldName;
+ }
+
+ public void setRelFieldName(String relFieldName) {
+ this.relFieldName = relFieldName;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.fieldName.hashCode() + this.relFieldName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof ModelKeyMap)) return false;
+ ModelKeyMap otherKeyMap = (ModelKeyMap) other;
+
+ if (!otherKeyMap.getFieldName().equals(this.fieldName)) return false;
+ if (!otherKeyMap.getRelFieldName().equals(this.relFieldName)) return false;
+
+ return true;
+ }
+
+ public Element toXmlElement(Document document) {
+ Element root = document.createElement("key-map");
+ root.setAttribute("field-name", this.getFieldName());
+ if (!this.getFieldName().equals(this.getRelFieldName())) {
+ root.setAttribute("rel-field-name", this.getRelFieldName());
+ }
+
+ return root;
+ }
+}
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelKeyMapImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelReader.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelReader.java Thu Aug 13 23:33:38 2009
@@ -307,7 +307,7 @@
}
// create the new relationship even if one exists so we can show what we are looking for in the info message
- ModelRelation newRel = new ModelRelation();
+ ModelRelationImpl newRel = new ModelRelationImpl();
newRel.setModelEntity(relatedEnt);
newRel.setRelEntityName(curModelEntity.getEntityName());
newRel.setTitle(targetTitle);
@@ -315,7 +315,7 @@
Set<String> curEntityKeyFields = FastSet.newInstance();
for (int kmn = 0; kmn < modelRelation.getKeyMapsSize(); kmn++) {
ModelKeyMap curkm = modelRelation.getKeyMap(kmn);
- ModelKeyMap newkm = new ModelKeyMap();
+ ModelKeyMap newkm = new ModelKeyMapImpl();
newRel.addKeyMap(newkm);
newkm.setFieldName(curkm.getRelFieldName());
newkm.setRelFieldName(curkm.getFieldName());
@@ -549,7 +549,7 @@
ModelEntity createModelEntity(Element entityElement, UtilTimer utilTimer, ModelInfo def) {
if (entityElement == null) return null;
this.numEntities++;
- ModelEntity entity = new ModelEntity(this, entityElement, utilTimer, def);
+ ModelEntity entity = new ModelEntityImpl(this, entityElement, utilTimer, def);
return entity;
}
@@ -562,13 +562,13 @@
public ModelRelation createRelation(ModelEntity entity, Element relationElement) {
this.numRelations++;
- ModelRelation relation = new ModelRelation(entity, relationElement);
+ ModelRelation relation = new ModelRelationImpl(entity, relationElement);
return relation;
}
public ModelField findModelField(ModelEntity entity, String fieldName) {
- for (ModelField field: entity.fields) {
- if (field.name.compareTo(fieldName) == 0) {
+ for (ModelField field: entity.getFieldsUnmodifiable()) {
+ if (field.getName().compareTo(fieldName) == 0) {
return field;
}
}
@@ -577,7 +577,7 @@
public ModelField createModelField(String name, String type, String colName, boolean isPk) {
this.numFields++;
- ModelField field = new ModelField(name, type, colName, isPk);
+ ModelField field = new ModelFieldImpl(name, type, colName, isPk);
return field;
}
@@ -587,7 +587,7 @@
}
this.numFields++;
- ModelField field = new ModelField(fieldElement);
+ ModelField field = new ModelFieldImpl(fieldElement);
return field;
}
}
Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java Thu Aug 13 23:33:38 2009
@@ -18,299 +18,70 @@
*/
package org.ofbiz.entity.model;
-import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
-import javolution.util.FastList;
-
-import org.ofbiz.base.util.StringUtil;
-import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.UtilXml;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
/**
* Generic Entity - Relation model class
*
*/
-public class ModelRelation extends ModelChild {
-
- /** the title, gives a name/description to the relation */
- protected String title;
+public interface ModelRelation {
- /** the type: either "one" or "many" or "one-nofk" */
- protected String type;
-
- /** the name of the related entity */
- protected String relEntityName;
+ /** Find a KeyMap with the specified fieldName */
+ public ModelKeyMap findKeyMap(String fieldName);
- /** the name to use for a database foreign key, if applies */
- protected String fkName;
+ /** Find a KeyMap with the specified relFieldName */
+ public ModelKeyMap findKeyMapByRelated(String relFieldName);
- /** keyMaps defining how to lookup the relatedTable using columns from this table */
- protected List<ModelKeyMap> keyMaps = new ArrayList<ModelKeyMap>();
+ public String getCombinedName();
- /** the main entity of this relation */
- protected ModelEntity mainEntity = null;
+ /** The description for documentation purposes */
+ public String getDescription();
- protected boolean isAutoRelation = false;
+ public String getFkName();
- /** Default Constructor */
- public ModelRelation() {
- title = "";
- type = "";
- relEntityName = "";
- fkName = "";
- }
-
- /** Default Constructor */
- public ModelRelation(String type, String title, String relEntityName, String fkName, List<ModelKeyMap> keyMaps) {
- this.title = title;
- if (title == null) title = "";
- this.type = type;
- this.relEntityName = relEntityName;
- this.fkName = fkName;
- this.keyMaps.addAll(keyMaps);
- }
-
- /** XML Constructor */
- public ModelRelation(ModelEntity mainEntity, Element relationElement) {
- this.mainEntity = mainEntity;
-
- this.type = UtilXml.checkEmpty(relationElement.getAttribute("type")).intern();
- this.title = UtilXml.checkEmpty(relationElement.getAttribute("title")).intern();
- this.relEntityName = UtilXml.checkEmpty(relationElement.getAttribute("rel-entity-name")).intern();
- this.fkName = UtilXml.checkEmpty(relationElement.getAttribute("fk-name")).intern();
- this.description = StringUtil.internString(UtilXml.childElementValue(relationElement, "description"));
-
- NodeList keyMapList = relationElement.getElementsByTagName("key-map");
- for (int i = 0; i < keyMapList.getLength(); i++) {
- Element keyMapElement = (Element) keyMapList.item(i);
-
- if (keyMapElement.getParentNode() == relationElement) {
- ModelKeyMap keyMap = new ModelKeyMap(keyMapElement);
-
- if (keyMap != null) {
- this.keyMaps.add(keyMap);
- }
- }
- }
- }
-
- public String getCombinedName() {
- return this.title + this.relEntityName;
- }
+ public ModelKeyMap getKeyMap(int index);
- /** the title, gives a name/description to the relation */
- public String getTitle() {
- if (this.title == null) {
- this.title = "";
- }
- return this.title;
- }
-
- public void setTitle(String title) {
- if (title == null) {
- this.title = "";
- } else {
- this.title = title;
- }
- }
+ public List<ModelKeyMap> getKeyMapsClone();
- /** the type: either "one" or "many" or "one-nofk" */
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
+ /** keyMaps defining how to lookup the relatedTable using columns from this table */
+ public Iterator<ModelKeyMap> getKeyMapsIterator();
- /** the name of the related entity */
- public String getRelEntityName() {
- return this.relEntityName;
- }
-
- public void setRelEntityName(String relEntityName) {
- this.relEntityName = relEntityName;
- }
-
- public String getFkName() {
- return this.fkName;
- }
-
- public void setFkName(String fkName) {
- this.fkName = fkName;
- }
+ public int getKeyMapsSize();
/** @deprecated
- * the main entity of this relation */
- @Deprecated
- public ModelEntity getMainEntity() {
- return getModelEntity();
- }
-
- /** @deprecated */
- @Deprecated
- public void setMainEntity(ModelEntity mainEntity) {
- setModelEntity(mainEntity);
- }
-
- /** keyMaps defining how to lookup the relatedTable using columns from this table */
- public Iterator<ModelKeyMap> getKeyMapsIterator() {
- return this.keyMaps.iterator();
- }
-
- public List<ModelKeyMap> getKeyMapsClone() {
- List<ModelKeyMap> kmList = FastList.newInstance();
- kmList.addAll(this.keyMaps);
- return kmList;
- }
-
- public int getKeyMapsSize() {
- return this.keyMaps.size();
- }
-
- public ModelKeyMap getKeyMap(int index) {
- return this.keyMaps.get(index);
- }
-
- public void addKeyMap(ModelKeyMap keyMap) {
- this.keyMaps.add(keyMap);
- }
-
- public ModelKeyMap removeKeyMap(int index) {
- return this.keyMaps.remove(index);
- }
+ * the main entity of this relation */
+ @Deprecated
+ public ModelEntity getMainEntity();
- /** Find a KeyMap with the specified fieldName */
- public ModelKeyMap findKeyMap(String fieldName) {
- for (ModelKeyMap keyMap: keyMaps) {
- if (keyMap.fieldName.equals(fieldName)) return keyMap;
- }
- return null;
- }
+ /** the name of the related entity */
+ public String getRelEntityName();
- /** Find a KeyMap with the specified relFieldName */
- public ModelKeyMap findKeyMapByRelated(String relFieldName) {
- for (ModelKeyMap keyMap: keyMaps) {
- if (keyMap.relFieldName.equals(relFieldName))
- return keyMap;
- }
- return null;
- }
-
- public String keyMapString(String separator, String afterLast) {
- String returnString = "";
-
- if (keyMaps.size() < 1) {
- return "";
- }
-
- int i = 0;
-
- for (; i < keyMaps.size() - 1; i++) {
- returnString = returnString + keyMaps.get(i).fieldName + separator;
- }
- returnString = returnString + keyMaps.get(i).fieldName + afterLast;
- return returnString;
- }
-
- public String keyMapUpperString(String separator, String afterLast) {
- if (keyMaps.size() < 1)
- return "";
-
- StringBuilder returnString = new StringBuilder( keyMaps.size() * 10 );
- int i=0;
- while (true) {
- ModelKeyMap kmap = keyMaps.get(i);
- returnString.append( ModelUtil.upperFirstChar( kmap.fieldName));
-
- i++;
- if (i >= keyMaps.size()) {
- returnString.append( afterLast );
- break;
- }
-
- returnString.append( separator );
- }
-
- return returnString.toString();
- }
-
- public String keyMapRelatedUpperString(String separator, String afterLast) {
- if (keyMaps.size() < 1)
- return "";
-
- StringBuilder returnString = new StringBuilder( keyMaps.size() * 10 );
- int i=0;
- while (true) {
- ModelKeyMap kmap = keyMaps.get(i);
- returnString.append( ModelUtil.upperFirstChar( kmap.relFieldName ));
-
- i++;
- if (i >= keyMaps.size()) {
- returnString.append( afterLast );
- break;
- }
+ /** the title, gives a name/description to the relation */
+ public String getTitle();
- returnString.append( separator );
- }
+ /** the type: either "one" or "many" or "one-nofk" */
+ public String getType();
- return returnString.toString();
- }
/**
* @return Returns the isAutoRelation.
*/
- public boolean isAutoRelation() {
- return isAutoRelation;
- }
+ public boolean isAutoRelation();
+
/**
* @param isAutoRelation The isAutoRelation to set.
*/
- public void setAutoRelation(boolean isAutoRelation) {
- this.isAutoRelation = isAutoRelation;
- }
-
- // FIXME: CCE
- @Override
- public boolean equals(Object other) {
- ModelRelation otherRel = (ModelRelation) other;
-
- if (!otherRel.type.equals(this.type)) return false;
- if (!otherRel.title.equals(this.title)) return false;
- if (!otherRel.relEntityName.equals(this.relEntityName)) return false;
-
- Set<ModelKeyMap> thisKeyNames = new HashSet<ModelKeyMap>(this.keyMaps);
- Set<ModelKeyMap> otherKeyNames = new HashSet<ModelKeyMap>(otherRel.keyMaps);
- if (!thisKeyNames.containsAll(otherKeyNames)) return false;
- if (!otherKeyNames.containsAll(thisKeyNames)) return false;
-
- return true;
- }
-
- public Element toXmlElement(Document document) {
- Element root = document.createElement("relation");
- root.setAttribute("type", this.getType());
- if (UtilValidate.isNotEmpty(this.getTitle())) {
- root.setAttribute("title", this.getTitle());
- }
- root.setAttribute("rel-entity-name", this.getRelEntityName());
-
- if (UtilValidate.isNotEmpty(this.getFkName())) {
- root.setAttribute("fk-name", this.getFkName());
- }
-
- Iterator<ModelKeyMap> kmIter = this.getKeyMapsIterator();
- while (kmIter != null && kmIter.hasNext()) {
- ModelKeyMap km = kmIter.next();
- root.appendChild(km.toXmlElement(document));
- }
+ public void setAutoRelation(boolean isAutoRelation);
+
+ public void setFkName(String fkName);
+
+ public void setRelEntityName(String relEntityName);
+
+ public void setTitle(String title);
+ public void setType(String type);
- return root;
- }
+ public Element toXmlElement(Document document);
}
Added: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java?rev=804060&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java (added)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java Thu Aug 13 23:33:38 2009
@@ -0,0 +1,316 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ofbiz.entity.model;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javolution.util.FastList;
+
+import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilXml;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Generic Entity - Relation model class
+ *
+ */
+public class ModelRelationImpl extends ModelChild implements ModelRelation {
+
+ /** the title, gives a name/description to the relation */
+ protected String title;
+
+ /** the type: either "one" or "many" or "one-nofk" */
+ protected String type;
+
+ /** the name of the related entity */
+ protected String relEntityName;
+
+ /** the name to use for a database foreign key, if applies */
+ protected String fkName;
+
+ /** keyMaps defining how to lookup the relatedTable using columns from this table */
+ protected List<ModelKeyMap> keyMaps = new ArrayList<ModelKeyMap>();
+
+ /** the main entity of this relation */
+ protected ModelEntity mainEntity = null;
+
+ protected boolean isAutoRelation = false;
+
+ /** Default Constructor */
+ public ModelRelationImpl() {
+ title = "";
+ type = "";
+ relEntityName = "";
+ fkName = "";
+ }
+
+ /** Default Constructor */
+ public ModelRelationImpl(String type, String title, String relEntityName, String fkName, List<ModelKeyMap> keyMaps) {
+ this.title = title;
+ if (title == null) title = "";
+ this.type = type;
+ this.relEntityName = relEntityName;
+ this.fkName = fkName;
+ this.keyMaps.addAll(keyMaps);
+ }
+
+ /** XML Constructor */
+ public ModelRelationImpl(ModelEntity mainEntity, Element relationElement) {
+ this.mainEntity = mainEntity;
+
+ this.type = UtilXml.checkEmpty(relationElement.getAttribute("type")).intern();
+ this.title = UtilXml.checkEmpty(relationElement.getAttribute("title")).intern();
+ this.relEntityName = UtilXml.checkEmpty(relationElement.getAttribute("rel-entity-name")).intern();
+ this.fkName = UtilXml.checkEmpty(relationElement.getAttribute("fk-name")).intern();
+ this.description = StringUtil.internString(UtilXml.childElementValue(relationElement, "description"));
+
+ NodeList keyMapList = relationElement.getElementsByTagName("key-map");
+ for (int i = 0; i < keyMapList.getLength(); i++) {
+ Element keyMapElement = (Element) keyMapList.item(i);
+
+ if (keyMapElement.getParentNode() == relationElement) {
+ ModelKeyMap keyMap = new ModelKeyMapImpl(keyMapElement);
+
+ if (keyMap != null) {
+ this.keyMaps.add(keyMap);
+ }
+ }
+ }
+ }
+
+ public String getCombinedName() {
+ return this.title + this.relEntityName;
+ }
+
+ /** the title, gives a name/description to the relation */
+ public String getTitle() {
+ if (this.title == null) {
+ this.title = "";
+ }
+ return this.title;
+ }
+
+ public void setTitle(String title) {
+ if (title == null) {
+ this.title = "";
+ } else {
+ this.title = title;
+ }
+ }
+
+ /** the type: either "one" or "many" or "one-nofk" */
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /** the name of the related entity */
+ public String getRelEntityName() {
+ return this.relEntityName;
+ }
+
+ public void setRelEntityName(String relEntityName) {
+ this.relEntityName = relEntityName;
+ }
+
+ public String getFkName() {
+ return this.fkName;
+ }
+
+ public void setFkName(String fkName) {
+ this.fkName = fkName;
+ }
+
+ /** @deprecated
+ * the main entity of this relation */
+ @Deprecated
+ public ModelEntity getMainEntity() {
+ return getModelEntity();
+ }
+
+ /** @deprecated */
+ @Deprecated
+ public void setMainEntity(ModelEntity mainEntity) {
+ setModelEntity(mainEntity);
+ }
+
+ /** keyMaps defining how to lookup the relatedTable using columns from this table */
+ public Iterator<ModelKeyMap> getKeyMapsIterator() {
+ return this.keyMaps.iterator();
+ }
+
+ public List<ModelKeyMap> getKeyMapsClone() {
+ List<ModelKeyMap> kmList = FastList.newInstance();
+ kmList.addAll(this.keyMaps);
+ return kmList;
+ }
+
+ public int getKeyMapsSize() {
+ return this.keyMaps.size();
+ }
+
+ public ModelKeyMap getKeyMap(int index) {
+ return this.keyMaps.get(index);
+ }
+
+ public void addKeyMap(ModelKeyMap keyMap) {
+ this.keyMaps.add(keyMap);
+ }
+
+ public ModelKeyMap removeKeyMap(int index) {
+ return this.keyMaps.remove(index);
+ }
+
+ /** Find a KeyMap with the specified fieldName */
+ public ModelKeyMap findKeyMap(String fieldName) {
+ for (ModelKeyMap keyMap: keyMaps) {
+ if (keyMap.getFieldName().equals(fieldName)) return keyMap;
+ }
+ return null;
+ }
+
+ /** Find a KeyMap with the specified relFieldName */
+ public ModelKeyMap findKeyMapByRelated(String relFieldName) {
+ for (ModelKeyMap keyMap: keyMaps) {
+ if (keyMap.getRelFieldName().equals(relFieldName))
+ return keyMap;
+ }
+ return null;
+ }
+
+ public String keyMapString(String separator, String afterLast) {
+ String returnString = "";
+
+ if (keyMaps.size() < 1) {
+ return "";
+ }
+
+ int i = 0;
+
+ for (; i < keyMaps.size() - 1; i++) {
+ returnString = returnString + keyMaps.get(i).getFieldName() + separator;
+ }
+ returnString = returnString + keyMaps.get(i).getFieldName() + afterLast;
+ return returnString;
+ }
+
+ public String keyMapUpperString(String separator, String afterLast) {
+ if (keyMaps.size() < 1)
+ return "";
+
+ StringBuilder returnString = new StringBuilder( keyMaps.size() * 10 );
+ int i=0;
+ while (true) {
+ ModelKeyMap kmap = keyMaps.get(i);
+ returnString.append( ModelUtil.upperFirstChar( kmap.getFieldName()));
+
+ i++;
+ if (i >= keyMaps.size()) {
+ returnString.append( afterLast );
+ break;
+ }
+
+ returnString.append( separator );
+ }
+
+ return returnString.toString();
+ }
+
+ public String keyMapRelatedUpperString(String separator, String afterLast) {
+ if (keyMaps.size() < 1)
+ return "";
+
+ StringBuilder returnString = new StringBuilder( keyMaps.size() * 10 );
+ int i=0;
+ while (true) {
+ ModelKeyMap kmap = keyMaps.get(i);
+ returnString.append( ModelUtil.upperFirstChar( kmap.getRelFieldName() ));
+
+ i++;
+ if (i >= keyMaps.size()) {
+ returnString.append( afterLast );
+ break;
+ }
+
+ returnString.append( separator );
+ }
+
+ return returnString.toString();
+ }
+ /**
+ * @return Returns the isAutoRelation.
+ */
+ public boolean isAutoRelation() {
+ return isAutoRelation;
+ }
+ /**
+ * @param isAutoRelation The isAutoRelation to set.
+ */
+ public void setAutoRelation(boolean isAutoRelation) {
+ this.isAutoRelation = isAutoRelation;
+ }
+
+ // FIXME: CCE
+ @Override
+ public boolean equals(Object other) {
+ ModelRelation otherRel = (ModelRelation) other;
+
+ if (!otherRel.getType().equals(this.type)) return false;
+ if (!otherRel.getTitle().equals(this.title)) return false;
+ if (!otherRel.getRelEntityName().equals(this.relEntityName)) return false;
+
+ Set<ModelKeyMap> thisKeyNames = new HashSet<ModelKeyMap>(this.keyMaps);
+ Set<ModelKeyMap> otherKeyNames = new HashSet<ModelKeyMap>(otherRel.getKeyMapsClone());
+ if (!thisKeyNames.containsAll(otherKeyNames)) return false;
+ if (!otherKeyNames.containsAll(thisKeyNames)) return false;
+
+ return true;
+ }
+
+ public Element toXmlElement(Document document) {
+ Element root = document.createElement("relation");
+ root.setAttribute("type", this.getType());
+ if (UtilValidate.isNotEmpty(this.getTitle())) {
+ root.setAttribute("title", this.getTitle());
+ }
+ root.setAttribute("rel-entity-name", this.getRelEntityName());
+
+ if (UtilValidate.isNotEmpty(this.getFkName())) {
+ root.setAttribute("fk-name", this.getFkName());
+ }
+
+ Iterator<ModelKeyMap> kmIter = this.getKeyMapsIterator();
+ while (kmIter != null && kmIter.hasNext()) {
+ ModelKeyMap km = kmIter.next();
+ root.appendChild(km.toXmlElement(document));
+ }
+
+ return root;
+ }
+}
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelRelationImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelUtil.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelUtil.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelUtil.java Thu Aug 13 23:33:38 2009
@@ -19,6 +19,9 @@
package org.ofbiz.entity.model;
import java.io.*;
+import java.util.List;
+
+import javolution.util.FastList;
import org.ofbiz.base.util.*;
@@ -292,4 +295,46 @@
return "invalid-" + sqlTypeName + ":" + length + ":" + precision;
}
}
+
+ // ======= ModelKeyMap Convenience Oriented Factory Methods ======= //
+
+ public static List<ModelKeyMap> makeKeyMapList(String fieldName1) {
+ return UtilMisc.toList(createModelKeyMap(fieldName1, null));
+ }
+
+ public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1) {
+ return UtilMisc.toList(createModelKeyMap(fieldName1, relFieldName1));
+ }
+
+ public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2) {
+ List<ModelKeyMap> modelKeyMapList = FastList.newInstance();
+ modelKeyMapList.add(createModelKeyMap(fieldName1, relFieldName1));
+ modelKeyMapList.add(createModelKeyMap(fieldName2, relFieldName2));
+ return modelKeyMapList;
+ }
+
+ public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2, String fieldName3, String relFieldName3) {
+ List<ModelKeyMap> modelKeyMapList = FastList.newInstance();
+ modelKeyMapList.add(createModelKeyMap(fieldName1, relFieldName1));
+ modelKeyMapList.add(createModelKeyMap(fieldName2, relFieldName2));
+ modelKeyMapList.add(createModelKeyMap(fieldName3, relFieldName3));
+ return modelKeyMapList;
+ }
+
+ public static ModelKeyMap createModelKeyMap(String fieldName, String relFieldName) {
+ ModelKeyMap modelKeyMap = null;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ modelKeyMap = (ModelKeyMap) loader.loadClass("org.ofbiz.entity.model.ModelKeyMapImpl").newInstance();
+ } catch (Exception e) {
+ Debug.logError(e, module);
+ }
+ modelKeyMap.setFieldName(fieldName);
+ modelKeyMap.setRelFieldName(UtilXml.checkEmpty(relFieldName, fieldName));
+ return modelKeyMap;
+ }
+
+ public static DynamicViewEntity createDynamicViewEntity() {
+ return new DynamicViewEntityImpl();
+ }
}
Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Thu Aug 13 23:33:38 2009
@@ -52,7 +52,7 @@
* This class extends ModelEntity and provides additional information appropriate to view entities
*/
@SuppressWarnings("serial")
-public class ModelViewEntity extends ModelEntity {
+public class ModelViewEntity extends ModelEntityImpl {
public static final String module = ModelViewEntity.class.getName();
public static Map<String, String> functionPrefixMap = FastMap.newInstance();
@@ -338,9 +338,9 @@
Iterator<ModelField> fldsIt = flds.iterator();
while (fldsIt.hasNext()) {
ModelField field = fldsIt.next();
- returnString.append(field.colName);
+ returnString.append(field.getColName());
if (alias) {
- ModelAlias modelAlias = this.getAlias(field.name);
+ ModelAlias modelAlias = this.getAlias(field.getName());
if (modelAlias != null) {
returnString.append(" AS " + modelAlias.getColAlias());
}
@@ -354,7 +354,7 @@
return returnString.toString();
}
- protected ModelEntity aliasedModelEntity = new ModelEntity();
+ protected ModelEntity aliasedModelEntity = new ModelEntityImpl();
public ModelEntity getAliasedModelEntity() {
return this.aliasedModelEntity;
@@ -408,7 +408,7 @@
Iterator<ModelField> aliasedFieldIterator = aliasedEntity.getFieldsIterator();
while (aliasedFieldIterator.hasNext()) {
ModelField aliasedModelField = aliasedFieldIterator.next();
- ModelField newModelField = new ModelField();
+ ModelField newModelField = new ModelFieldImpl();
for (int i = 0; i < aliasedModelField.getValidatorsSize(); i++) {
newModelField.addValidator(aliasedModelField.getValidator(i));
}
@@ -424,9 +424,9 @@
expandAllAliasAlls(modelReader);
for (ModelAlias alias: aliases) {
- ModelField field = new ModelField();
+ ModelFieldImpl field = new ModelFieldImpl();
field.setModelEntity(this);
- field.name = alias.name;
+ field.setName(alias.name);
field.description = alias.description;
// if this is a groupBy field, add it to the groupBys list
@@ -449,7 +449,7 @@
field.isPk = false;
} else {
ModelEntity aliasedEntity = getAliasedEntity(alias.entityAlias, modelReader);
- ModelField aliasedField = getAliasedField(aliasedEntity, alias.field, modelReader);
+ ModelFieldImpl aliasedField = (ModelFieldImpl) getAliasedField(aliasedEntity, alias.field, modelReader);
if (aliasedField == null) {
Debug.logError("[ModelViewEntity.populateFields (" + this.getEntityName() + ")] ERROR: could not find ModelField for field name \"" +
alias.field + "\" on entity with name: " + aliasedEntity.getEntityName(), module);
@@ -467,7 +467,7 @@
field.type = aliasedField.type;
field.validators = aliasedField.validators;
- field.colName = alias.entityAlias + "." + SqlJdbcUtil.filterColName(aliasedField.colName);
+ field.colName = alias.entityAlias + "." + SqlJdbcUtil.filterColName(aliasedField.getColName());
if (UtilValidate.isEmpty(field.description)) {
field.description = aliasedField.description;
}
@@ -490,7 +490,7 @@
if (prefix == null) {
Debug.logWarning("Specified alias function [" + alias.function + "] not valid; must be: min, max, sum, avg, count or count-distinct; using a column name with no function function", module);
} else {
- field.colName = prefix + field.colName + ")";
+ field.setColName(prefix + field.getColName() + ")");
}
}
}
@@ -987,7 +987,7 @@
//set fieldTypeBuffer if not already set
if (fieldTypeBuffer.length() == 0) {
- fieldTypeBuffer.append(modelField.type);
+ fieldTypeBuffer.append(modelField.getType());
}
}
}
@@ -1010,7 +1010,7 @@
NodeList keyMapList = viewLinkElement.getElementsByTagName("key-map");
for (int j = 0; j < keyMapList.getLength(); j++) {
Element keyMapElement = (Element) keyMapList.item(j);
- ModelKeyMap keyMap = new ModelKeyMap(keyMapElement);
+ ModelKeyMap keyMap = new ModelKeyMapImpl(keyMapElement);
if (keyMap != null) keyMaps.add(keyMap);
}
Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Thu Aug 13 23:33:38 2009
@@ -29,7 +29,7 @@
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.entity.GenericEntity;
+import org.ofbiz.entity.EntityFactory;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;
@@ -113,7 +113,7 @@
public void testCreateTree() throws Exception {
try {
// get how many child nodes did we have before creating the tree
- EntityCondition isChild = EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD);
+ EntityCondition isChild = EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, EntityFactory.NULL_FIELD);
long alreadyStored = delegator.findCountByCondition("TestingNode", isChild, null, null);
//
@@ -123,7 +123,7 @@
// create the root
GenericValue root = delegator.create("TestingNode",
"testingNodeId", delegator.getNextSeqId("TestingNode"),
- "primaryParentNodeId", GenericEntity.NULL_FIELD,
+ "primaryParentNodeId", EntityFactory.NULL_FIELD,
"description", "root");
int level1;
for(level1 = 0; level1 < _level1max; level1++) {
@@ -148,7 +148,7 @@
*/
public void testAddMembersToTree() throws Exception {
// get the level1 nodes
- EntityCondition isLevel1 = EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD);
+ EntityCondition isLevel1 = EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, EntityFactory.NULL_FIELD);
List<GenericValue> nodeLevel1 = delegator.findList("TestingNode", isLevel1, null, null, null, false);
List<GenericValue> newValues = new LinkedList<GenericValue>();
@@ -184,7 +184,7 @@
* Tests findByCondition and tests searching on a view-entity
*/
public void testCountViews() throws Exception {
- EntityCondition isNodeWithMember = EntityCondition.makeCondition("testingId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD);
+ EntityCondition isNodeWithMember = EntityCondition.makeCondition("testingId", EntityOperator.NOT_EQUAL, EntityFactory.NULL_FIELD);
List<GenericValue> nodeWithMembers = delegator.findList("TestingNodeAndMember", isNodeWithMember, null, null, null, false);
for (GenericValue v: nodeWithMembers) {
@@ -331,7 +331,7 @@
// Find all the root nodes,
// delete them their primary key
//
- EntityCondition isRoot = EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.EQUALS, GenericEntity.NULL_FIELD);
+ EntityCondition isRoot = EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.EQUALS, EntityFactory.NULL_FIELD);
List<GenericValue> rootValues = delegator.findList("TestingNode", isRoot, UtilMisc.toSet("testingNodeId"), null, null, false);
for (GenericValue value: rootValues) {
Modified: ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java Thu Aug 13 23:33:38 2009
@@ -42,6 +42,7 @@
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.entity.DelegatorFactory;
+import org.ofbiz.entity.EntityFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
Modified: ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java Thu Aug 13 23:33:38 2009
@@ -45,7 +45,7 @@
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.cache.UtilCache;
-import org.ofbiz.entity.GenericEntity;
+import org.ofbiz.entity.EntityFactory;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.transaction.GenericTransactionException;
import org.ofbiz.entity.transaction.TransactionUtil;
@@ -632,8 +632,8 @@
/** Execute the Simple Method operations */
public String exec(MethodContext methodContext) {
// always put the null field object in as "null"
- methodContext.putEnv("null", GenericEntity.NULL_FIELD);
- methodContext.putEnv("nullField", GenericEntity.NULL_FIELD);
+ methodContext.putEnv("null", EntityFactory.NULL_FIELD);
+ methodContext.putEnv("nullField", EntityFactory.NULL_FIELD);
methodContext.putEnv(delegatorName, methodContext.getDelegator());
methodContext.putEnv(securityName, methodContext.getSecurity());
Modified: ofbiz/branches/executioncontext20090812/framework/webslinger/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/webslinger/build.xml?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/webslinger/build.xml (original)
+++ ofbiz/branches/executioncontext20090812/framework/webslinger/build.xml Thu Aug 13 23:33:38 2009
@@ -31,6 +31,7 @@
<path id="local.class.path">
<fileset dir="lib" includes="*.jar"/>
+ <fileset dir="${ofbiz.home.dir}/framework/api/build/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/entity/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/entity/build/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="*.jar"/>
Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java Thu Aug 13 23:33:38 2009
@@ -32,8 +32,8 @@
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.string.FlexibleStringExpander;
+import org.ofbiz.entity.EntityFactory;
import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.service.ExecutionContext;
@@ -350,7 +350,7 @@
ExecutionContext executionContext = (ExecutionContext) context.get("executionContext");
executionContext.pushExecutionArtifact(this);
// make sure the "null" object is in there for entity ops
- context.put("null", GenericEntity.NULL_FIELD);
+ context.put("null", EntityFactory.NULL_FIELD);
setWidgetBoundaryComments(context);
Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Thu Aug 13 23:33:38 2009
@@ -44,8 +44,8 @@
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.collections.MapStack;
+import org.ofbiz.entity.EntityFactory;
import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.security.Security;
import org.ofbiz.security.authz.Authorization;
@@ -152,7 +152,7 @@
context.put("globalContext", context.standAloneStack());
// make sure the "nullField" object is in there for entity ops; note this is nullField and not null because as null causes problems in FreeMarker and such...
- context.put("nullField", GenericEntity.NULL_FIELD);
+ context.put("nullField", EntityFactory.NULL_FIELD);
context.put("parameters", parameters);
context.put("delegator", delegator);
Modified: ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/ActivityIteratorCondExprBldr.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/ActivityIteratorCondExprBldr.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/ActivityIteratorCondExprBldr.java (original)
+++ ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/ActivityIteratorCondExprBldr.java Thu Aug 13 23:33:38 2009
@@ -42,7 +42,7 @@
public void addProcess(String field, String fieldAlias) {
if (!addedProcess) {
this.addEntity("WFPR", org.ofbiz.shark.SharkConstants.WfProcess);
- this.addLink("WFAC", "WFAC", false, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId));
+ this.addLink("WFAC", "WFAC", false, ModelUtil.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId));
}
this.addField("WFPR", field, fieldAlias);
}
Modified: ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/BaseEntityCondExprBldr.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/BaseEntityCondExprBldr.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/BaseEntityCondExprBldr.java (original)
+++ ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/expression/BaseEntityCondExprBldr.java Thu Aug 13 23:33:38 2009
@@ -150,7 +150,7 @@
}
private DynamicViewEntity makeView() {
- DynamicViewEntity view = new DynamicViewEntity();
+ DynamicViewEntity view = ModelUtil.createDynamicViewEntity();
// create the members
Modified: ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java?rev=804060&r1=804059&r2=804060&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java (original)
+++ ofbiz/branches/executioncontext20090812/specialpurpose/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java Thu Aug 13 23:33:38 2009
@@ -785,14 +785,14 @@
GenericDelegator delegator = SharkContainer.getDelegator();
List processIds = new ArrayList();
- DynamicViewEntity view = new DynamicViewEntity();
+ DynamicViewEntity view = ModelUtil.createDynamicViewEntity();
view.addMemberEntity("WFDL", org.ofbiz.shark.SharkConstants.WfDeadline);
view.addMemberEntity("WFPR", org.ofbiz.shark.SharkConstants.WfProcess);
view.addMemberEntity("WFAC", org.ofbiz.shark.SharkConstants.WfActivity);
view.addAlias("WFPR", org.ofbiz.shark.SharkConstants.currentState, "processState", null, null, null, null);
view.addAlias("WFAC", org.ofbiz.shark.SharkConstants.currentState, "activityState", null, null, null, null);
- view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId));
- view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.activityId));
+ view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelUtil.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId));
+ view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelUtil.makeKeyMapList(org.ofbiz.shark.SharkConstants.activityId));
EntityListIterator eli = null;
try {