1 24 25 package org.ofbiz.entity.condition; 26 27 28 import org.ofbiz.entity.GenericEntityException; 29 import org.ofbiz.entity.model.ModelEntity; 30 import org.ofbiz.entity.model.ModelReader; 31 32 33 41 public class EntityClause { 42 43 private String firstEntity = ""; 44 private String secondEntity = ""; 45 private String firstField = ""; 46 private String secondField = ""; 47 private ModelEntity firstModelEntity = null; 48 private ModelEntity secondModelEntity = null; 49 private EntityOperator interFieldOperation = null; 50 private EntityOperator intraFieldOperation = null; 51 52 private Object value = null; 53 public EntityClause() {} 54 55 public EntityClause(String firstEntity, String secondEntity, String firstField, String secondField, EntityOperator interFieldOperation, EntityOperator intraFieldOperation) { 56 this.firstEntity = firstEntity; 57 this.secondEntity = secondEntity; 58 this.firstField = firstField; 59 this.secondField = secondField; 60 this.interFieldOperation = interFieldOperation; 61 this.intraFieldOperation = intraFieldOperation; 62 } 63 64 public EntityClause(String firstEntity, String firstField, Object value, EntityOperator interFieldOperation, EntityOperator intraFieldOperation) { 65 this.firstEntity = firstEntity; 66 this.firstField = firstField; 67 this.value = value; 68 this.interFieldOperation = interFieldOperation; 69 this.intraFieldOperation = intraFieldOperation; 70 } 71 72 public String getFirstEntity() { 73 return firstEntity; 74 } 75 76 public String getSecondEntity() { 77 return secondEntity; 78 } 79 80 public String getFirstField() { 81 return firstField; 82 } 83 84 public String getSecondField() { 85 return secondField; 86 } 87 88 public Object getValue() { 89 if (value == null) value = new Object (); 90 return value; 91 } 92 93 public EntityOperator getInterFieldOperation() { 94 return interFieldOperation; 95 } 96 97 public EntityOperator getIntraFieldOperation() { 98 return intraFieldOperation; 99 } 100 101 public void setFirstEntity(String firstEntity) { 102 this.firstEntity = firstEntity; 103 } 104 105 public void setSecondEntity(String secondEntity) { 106 this.secondEntity = secondEntity; 107 } 108 109 public void setFirstField(String firstField) { 110 this.firstField = firstField; 111 } 112 113 public void setSecondField(String secondField) { 114 this.secondField = secondField; 115 } 116 117 public void setInterFieldOperation(EntityOperator interFieldOperation) { 118 this.interFieldOperation = interFieldOperation; 119 } 120 121 public void setIntraFieldOperation(EntityOperator intraFieldOperation) { 122 this.intraFieldOperation = intraFieldOperation; 123 } 124 125 protected void setModelEntities(ModelReader modelReader) throws GenericEntityException { 127 firstModelEntity = (ModelEntity) modelReader.getModelEntity(firstEntity); 128 if (secondEntity != null && !secondEntity.equals("")) { 129 secondModelEntity = (ModelEntity) modelReader.getModelEntity(secondEntity); 130 } 131 } 132 133 protected ModelEntity getFirstModelEntity() { 134 return firstModelEntity; 135 } 136 137 protected ModelEntity getSecondModelEntity() { 138 return secondModelEntity; 139 } 140 141 public String toString() { 142 StringBuffer outputBuffer = new StringBuffer (); 143 144 outputBuffer.append("[firstEntity," + (firstEntity == null ? "null" : firstEntity) + "]"); 145 outputBuffer.append("[secondEntity," + (secondEntity == null ? "null" : secondEntity) + "]"); 146 outputBuffer.append("[firstField," + (firstField == null ? "null" : firstField) + "]"); 147 outputBuffer.append("[secondField," + (secondField == null ? "null" : secondField) + "]"); 148 outputBuffer.append("[firstModelEntity," + (firstModelEntity == null ? "null" : (firstModelEntity.getEntityName() == null ? "null" : firstModelEntity.getEntityName())) + "]"); 149 outputBuffer.append("[secondModelEntity," + (secondModelEntity == null ? "null" : (secondModelEntity.getEntityName() == null ? "null" : secondModelEntity.getEntityName())) + "]"); 150 outputBuffer.append("[interFieldOperation," + (interFieldOperation == null ? "null" : (interFieldOperation.getCode() == null ? "null" : interFieldOperation.getCode())) + "]"); 151 outputBuffer.append("[intraFieldOperation," + (intraFieldOperation == null ? "null" : (intraFieldOperation.getCode() == null ? "null" : intraFieldOperation.getCode())) + "]"); 152 outputBuffer.append("[value," + (getValue().toString() == null ? "null" : getValue().toString()) + "]"); 153 return outputBuffer.toString(); 154 } 155 156 } 157 | Popular Tags |