|
Author: jaz
Date: Mon Dec 6 21:07:48 2010 New Revision: 1042792 URL: http://svn.apache.org/viewvc?rev=1042792&view=rev Log: implemented option to specific a specific entity should NOT be checked; no columns are to be updated and ignore any warning about fields, relations, keys, etc. This is useful when an entity is defined based on a database view; the view may not (or probably will not) appear in the table meta data and any attempt to auto-create the entity will (or should) fail. Modified: ofbiz/trunk/framework/entity/dtd/entitymodel.xsd ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java Modified: ofbiz/trunk/framework/entity/dtd/entitymodel.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/dtd/entitymodel.xsd?rev=1042792&r1=1042791&r2=1042792&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/dtd/entitymodel.xsd (original) +++ ofbiz/trunk/framework/entity/dtd/entitymodel.xsd Mon Dec 6 21:07:48 2010 @@ -90,6 +90,7 @@ under the License. <xs:attribute name="enable-lock" default="false" type="boolean"/> <xs:attribute name="no-auto-stamp" default="false" type="boolean"/> <xs:attribute name="never-cache" default="false" type="boolean"/> + <xs:attribute name="never-check" default="false" type="boolean"/> <xs:attribute name="auto-clear-cache" default="true" type="boolean"/> <xs:attribute name="title" type="xs:string"/> <xs:attribute name="copyright" type="xs:string"/> Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java?rev=1042792&r1=1042791&r2=1042792&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java Mon Dec 6 21:07:48 2010 @@ -205,6 +205,12 @@ public class DatabaseUtil { String entMessage = "(" + timer.timeSinceLast() + "ms) NOT Checking #" + curEnt + "/" + totalEnt + " View Entity " + entity.getEntityName(); Debug.logVerbose(entMessage, module); if (messages != null) messages.add(entMessage); + continue; + // if never-check is set then don't check it either + } else if (entity.getNeverCheck()) { + String entMessage = "(" + timer.timeSinceLast() + "ms) NOT Checking #" + curEnt + "/" + totalEnt + " Entity " + entity.getEntityName(); + Debug.logVerbose(entMessage, module); + if (messages != null) messages.add(entMessage); continue; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=1042792&r1=1042791&r2=1042792&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Mon Dec 6 21:07:48 2010 @@ -123,6 +123,7 @@ public class ModelEntity extends ModelIn * from cache on read showing a warning messages to that effect */ protected boolean neverCache = false; + protected boolean neverCheck = false; protected boolean autoClearCache = true; @@ -257,6 +258,7 @@ public class ModelEntity extends ModelIn this.doLock = UtilXml.checkBoolean(entityElement.getAttribute("enable-lock"), false); this.noAutoStamp = UtilXml.checkBoolean(entityElement.getAttribute("no-auto-stamp"), false); this.neverCache = UtilXml.checkBoolean(entityElement.getAttribute("never-cache"), false); + this.neverCheck = UtilXml.checkBoolean(entityElement.getAttribute("never-check"), false); this.autoClearCache = UtilXml.checkBoolean(entityElement.getAttribute("auto-clear-cache"), true); String sequenceBankSizeStr = UtilXml.checkEmpty(entityElement.getAttribute("sequence-bank-size")); @@ -408,7 +410,20 @@ public class ModelEntity extends ModelIn public void setNeverCache(boolean neverCache) { this.neverCache = neverCache; } - + + /** + * An indicator to specific if this entity should ignore automatic DB checks. + * This should be set when the entity is mapped to a database view to prevent + * warnings and attempts to modify the schema. + */ + public boolean getNeverCheck() { + return neverCheck; + } + + public void setNeverCheck(boolean neverCheck) { + this.neverCheck = neverCheck; + } + public boolean getAutoClearCache() { return this.autoClearCache; } @@ -1410,6 +1425,10 @@ public class ModelEntity extends ModelIn if (this.getNeverCache()) { root.setAttribute("never-cache", "true"); } + + if (this.getNeverCheck()) { + root.setAttribute("never-check", "true"); + } if (!this.getAutoClearCache()) { root.setAttribute("auto-clear-cache", "false"); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java?rev=1042792&r1=1042791&r2=1042792&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java Mon Dec 6 21:07:48 2010 @@ -94,6 +94,12 @@ public class ModelEntityChecker { if (entity.getPlainTableName() != null && reservedWords.contains(entity.getPlainTableName().toUpperCase())) { warningList.add("[TableNameRW] Table name [" + entity.getPlainTableName() + "] of entity " + entity.getEntityName() + " is a reserved word."); } + + // don't check columns/relations/keys when never-check is set to "true" + if (entity.getNeverCheck()) { + continue; + } + TreeSet<String> ufields = new TreeSet<String>(); Iterator<ModelField> fieldIter = entity.getFieldsIterator(); while (fieldIter.hasNext()) { |
| Free forum by Nabble | Edit this page |
