You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/18 05:49:12 UTC
svn commit: r585839 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity:
GenericEntity.java GenericValue.java
Author: doogie
Date: Wed Oct 17 20:49:12 2007
New Revision: 585839
URL: http://svn.apache.org/viewvc?rev=585839&view=rev
Log:
Java 1.5 markup after model support added.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=585839&r1=585838&r2=585839&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Wed Oct 17 20:49:12 2007
@@ -316,9 +316,9 @@
}
public boolean isPrimaryKey(boolean requireValue) {
TreeSet<String> fieldKeys = new TreeSet<String>(this.fields.keySet());
- Iterator pkIter = getModelEntity().getPksIterator();
+ Iterator<ModelField> pkIter = getModelEntity().getPksIterator();
while (pkIter.hasNext()) {
- ModelField curPk = (ModelField) pkIter.next();
+ ModelField curPk = pkIter.next();
String fieldName = curPk.getName();
if (requireValue) {
if (this.fields.get(fieldName) == null) return false;
@@ -536,12 +536,12 @@
}
public void setNextSeqId() {
- List pkFieldNameList = this.modelEntity.getPkFieldNames();
+ List<String> pkFieldNameList = this.modelEntity.getPkFieldNames();
if (pkFieldNameList.size() != 1) {
throw new IllegalArgumentException("Cannot setNextSeqId for entity [" + this.getEntityName() + "] that does not have a single primary key field, instead has [" + pkFieldNameList.size() + "]");
}
- String pkFieldName = (String) pkFieldNameList.get(0);
+ String pkFieldName = pkFieldNameList.get(0);
if (this.get(pkFieldName) != null) {
// don't throw exception, too much of a pain and usually intended: throw new IllegalArgumentException("Cannot setNextSeqId, pk field [" + pkFieldName + "] of entity [" + this.getEntityName() + "] already has a value [" + this.get(pkFieldName) + "]");
}
@@ -693,9 +693,9 @@
ModelEntity modelEntityToUse = this.getModelEntity();
if (modelEntityToUse instanceof ModelViewEntity) {
ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntityToUse;
- Iterator it = modelViewEntity.getAliasesIterator();
+ Iterator<ModelAlias> it = modelViewEntity.getAliasesIterator();
while (it.hasNext()) {
- ModelAlias modelAlias = (ModelAlias) it.next();
+ ModelAlias modelAlias = it.next();
if (modelAlias.getName().equalsIgnoreCase(name)) {
modelEntityToUse = modelViewEntity.getMemberModelEntity(modelAlias.getEntityAlias());
name = modelAlias.getField();
@@ -729,9 +729,9 @@
keyBuffer.append('.');
keyBuffer.append(name);
// finish off by adding the values of all PK fields
- Iterator iter = modelEntityToUse.getPksIterator();
+ Iterator<ModelField> iter = modelEntityToUse.getPksIterator();
while (iter != null && iter.hasNext()) {
- ModelField curField = (ModelField) iter.next();
+ ModelField curField = iter.next();
keyBuffer.append('.');
keyBuffer.append(this.get(curField.getName()));
}
@@ -753,9 +753,9 @@
public GenericPK getPrimaryKey() {
Collection<String> pkNames = FastList.newInstance();
- Iterator iter = this.getModelEntity().getPksIterator();
+ Iterator<ModelField> iter = this.getModelEntity().getPksIterator();
while (iter != null && iter.hasNext()) {
- ModelField curField = (ModelField) iter.next();
+ ModelField curField = iter.next();
pkNames.add(curField.getName());
}
GenericPK newPK = GenericPK.create(getModelEntity(), this.getFields(pkNames));
@@ -794,7 +794,7 @@
if (fields == null) {
return;
}
- Iterator iter = null;
+ Iterator<ModelField> iter = null;
if (pks != null) {
if (pks.booleanValue()) {
iter = this.getModelEntity().getPksIterator();
@@ -806,7 +806,7 @@
}
while (iter != null && iter.hasNext()) {
- ModelField curField = (ModelField) iter.next();
+ ModelField curField = iter.next();
String fieldName = curField.getName();
String sourceFieldName = null;
if (UtilValidate.isNotEmpty(namePrefix)) {
@@ -989,9 +989,9 @@
// write attributes immediately and if a CDATA element is needed, put those in a Map for now
Map<String, String> cdataMap = FastMap.newInstance();
- Iterator modelFields = this.getModelEntity().getFieldsIterator();
+ Iterator<ModelField> modelFields = this.getModelEntity().getFieldsIterator();
while (modelFields.hasNext()) {
- ModelField modelField = (ModelField) modelFields.next();
+ ModelField modelField = modelFields.next();
String name = modelField.getName();
String type = modelField.getType();
@@ -1248,17 +1248,17 @@
if (tempResult != 0) return tempResult;
// both have same entityName, should be the same so let's compare PKs
- Iterator pkIter = getModelEntity().getPksIterator();
+ Iterator<ModelField> pkIter = getModelEntity().getPksIterator();
while (pkIter.hasNext()) {
- ModelField curField = (ModelField) pkIter.next();
+ ModelField curField = pkIter.next();
tempResult = compareToFields(that, curField.getName());
if (tempResult != 0) return tempResult;
}
// okay, if we got here it means the primaryKeys are exactly the SAME, so compare the rest of the fields
- Iterator nopkIter = getModelEntity().getNopksIterator();
+ Iterator<ModelField> nopkIter = getModelEntity().getNopksIterator();
while (nopkIter.hasNext()) {
- ModelField curField = (ModelField) nopkIter.next();
+ ModelField curField = nopkIter.next();
if (!curField.getIsAutoCreatedInternal()) {
tempResult = compareToFields(that, curField.getName());
if (tempResult != 0) return tempResult;
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java?rev=585839&r1=585838&r2=585839&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Wed Oct 17 20:49:12 2007
@@ -434,9 +434,9 @@
*/
public boolean checkFks(boolean insertDummy) throws GenericEntityException {
ModelEntity model = this.getModelEntity();
- Iterator relItr = model.getRelationsIterator();
+ Iterator<ModelRelation> relItr = model.getRelationsIterator();
while (relItr.hasNext()) {
- ModelRelation relation = (ModelRelation) relItr.next();
+ ModelRelation relation = relItr.next();
if ("one".equalsIgnoreCase(relation.getType())) {
// see if the related value exists
Map<String, Object> fields = FastMap.newInstance();
@@ -449,10 +449,10 @@
if (insertDummy) {
// create the new related value (dummy)
GenericValue newValue = this.getDelegator().makeValue(relation.getRelEntityName());
- Iterator keyMapIter = relation.getKeyMapsIterator();
+ Iterator<ModelKeyMap> keyMapIter = relation.getKeyMapsIterator();
boolean allFieldsSet = true;
while (keyMapIter.hasNext()) {
- ModelKeyMap mkm = (ModelKeyMap) keyMapIter.next();
+ ModelKeyMap mkm = keyMapIter.next();
if (this.get(mkm.getFieldName()) != null) {
newValue.set(mkm.getRelFieldName(), this.get(mkm.getFieldName()));
if (Debug.infoOn()) Debug.logInfo("Set [" + mkm.getRelFieldName() + "] to - " + this.get(mkm.getFieldName()), module);