Improved: Updated case indentation to 0 for all switch statements in framework component. Also done formatting changes as per checkstyle best practices.
(OFBIZ-11904)
This commit is contained in:
@@ -820,25 +820,25 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
ModelEntity modelEntityToUse = this.getModelEntity();
|
||||
Object resourceValue = get(this.getModelEntity(), modelEntityToUse, name, resource, locale);
|
||||
if (resourceValue == null) {
|
||||
if (modelEntityToUse instanceof ModelViewEntity) {
|
||||
// now try to retrieve with the field heading from the real entity linked to the view
|
||||
ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntityToUse;
|
||||
Iterator<ModelAlias> it = modelViewEntity.getAliasesIterator();
|
||||
while (it.hasNext()) {
|
||||
ModelAlias modelAlias = it.next();
|
||||
if (modelAlias.getName().equalsIgnoreCase(name)) {
|
||||
modelEntityToUse = modelViewEntity.getMemberModelEntity(modelAlias.getEntityAlias());
|
||||
name = modelAlias.getField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
resourceValue = get(this.getModelEntity(), modelEntityToUse, name, resource, locale);
|
||||
if (resourceValue == null) {
|
||||
return fieldValue;
|
||||
}
|
||||
return resourceValue;
|
||||
}
|
||||
return fieldValue;
|
||||
if (modelEntityToUse instanceof ModelViewEntity) {
|
||||
// now try to retrieve with the field heading from the real entity linked to the view
|
||||
ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntityToUse;
|
||||
Iterator<ModelAlias> it = modelViewEntity.getAliasesIterator();
|
||||
while (it.hasNext()) {
|
||||
ModelAlias modelAlias = it.next();
|
||||
if (modelAlias.getName().equalsIgnoreCase(name)) {
|
||||
modelEntityToUse = modelViewEntity.getMemberModelEntity(modelAlias.getEntityAlias());
|
||||
name = modelAlias.getField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
resourceValue = get(this.getModelEntity(), modelEntityToUse, name, resource, locale);
|
||||
if (resourceValue == null) {
|
||||
return fieldValue;
|
||||
}
|
||||
return resourceValue;
|
||||
}
|
||||
return fieldValue;
|
||||
}
|
||||
return resourceValue;
|
||||
}
|
||||
@@ -1217,19 +1217,19 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
|
||||
switch (curChar) {
|
||||
case '\'':
|
||||
value.replace(i, i+1, "'");
|
||||
value.replace(i, i + 1, "'");
|
||||
break;
|
||||
case '"':
|
||||
value.replace(i, i+1, """);
|
||||
value.replace(i, i + 1, """);
|
||||
break;
|
||||
case '&':
|
||||
value.replace(i, i+1, "&");
|
||||
value.replace(i, i + 1, "&");
|
||||
break;
|
||||
case '<':
|
||||
value.replace(i, i+1, "<");
|
||||
value.replace(i, i + 1, "<");
|
||||
break;
|
||||
case '>':
|
||||
value.replace(i, i+1, ">");
|
||||
value.replace(i, i + 1, ">");
|
||||
break;
|
||||
case 0xA: // newline, \n
|
||||
needsCdata = true;
|
||||
@@ -1241,25 +1241,25 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
// do nothing, just catch here so it doesn't get into the default
|
||||
break;
|
||||
case 0x5: // elipses (...)
|
||||
value.replace(i, i+1, "...");
|
||||
value.replace(i, i + 1, "...");
|
||||
break;
|
||||
case 0x12: // apostrophe
|
||||
value.replace(i, i+1, "'");
|
||||
value.replace(i, i + 1, "'");
|
||||
break;
|
||||
case 0x13: // left quote
|
||||
value.replace(i, i+1, """);
|
||||
value.replace(i, i + 1, """);
|
||||
break;
|
||||
case 0x14: // right quote
|
||||
value.replace(i, i+1, """);
|
||||
value.replace(i, i + 1, """);
|
||||
break;
|
||||
case 0x16: // big(?) dash -
|
||||
value.replace(i, i+1, "-");
|
||||
value.replace(i, i + 1, "-");
|
||||
break;
|
||||
case 0x17: // dash -
|
||||
value.replace(i, i+1, "-");
|
||||
value.replace(i, i + 1, "-");
|
||||
break;
|
||||
case 0x19: // tm
|
||||
value.replace(i, i+1, "tm");
|
||||
value.replace(i, i + 1, "tm");
|
||||
break;
|
||||
default:
|
||||
if (curChar < 0x20) {
|
||||
@@ -1272,7 +1272,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Entity: " + this.getEntityName() + ", PK: " + this.getPrimaryKey().toString() + " -> char [" + curChar + "] replaced with [" + replacement + "]", MODULE);
|
||||
}
|
||||
value.replace(i, i+1, replacement);
|
||||
value.replace(i, i + 1, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class EntityClause {
|
||||
private String secondField = "";
|
||||
private ModelEntity firstModelEntity = null;
|
||||
private ModelEntity secondModelEntity = null;
|
||||
private EntityOperator<?,?> interFieldOperation = null;
|
||||
private EntityOperator<?,?> intraFieldOperation = null;
|
||||
private EntityOperator<?, ?> interFieldOperation = null;
|
||||
private EntityOperator<?, ?> intraFieldOperation = null;
|
||||
|
||||
private Object value = null;
|
||||
public EntityClause() { }
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ public final class EntityFieldMap extends EntityConditionListBase<EntityExpr> {
|
||||
* @param <V> The type of values that are compared.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public <V> EntityFieldMap(EntityComparisonOperator<?,?> compOp, EntityJoinOperator joinOp, V... keysValues) {
|
||||
public <V> EntityFieldMap(EntityComparisonOperator<?, ?> compOp, EntityJoinOperator joinOp, V... keysValues) {
|
||||
this(EntityUtil.makeFields(keysValues), UtilGenerics.cast(compOp), joinOp);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class EntityFieldMap extends EntityConditionListBase<EntityExpr> {
|
||||
* @param joinOp the operator to join entries in the field map
|
||||
* @param <V> the type of values contained in {@code fieldMap}
|
||||
*/
|
||||
public <V> EntityFieldMap(Map<String, V> fieldMap, EntityComparisonOperator<?,?> compOp,
|
||||
public <V> EntityFieldMap(Map<String, V> fieldMap, EntityComparisonOperator<?, ?> compOp,
|
||||
EntityJoinOperator joinOp) {
|
||||
super(makeConditionList(fieldMap, UtilGenerics.cast(compOp)), joinOp);
|
||||
this.fieldMap = (fieldMap == null) ? Collections.emptyMap() : fieldMap;
|
||||
|
||||
+108
-61
@@ -59,7 +59,7 @@ public abstract class EntityOperator<L, R> implements Serializable {
|
||||
public static final int ID_NOT_IN = 13;
|
||||
public static final int ID_NOT_LIKE = 14;
|
||||
|
||||
private static HashMap<String, EntityOperator<?,?>> registry = new HashMap<>();
|
||||
private static HashMap<String, EntityOperator<?, ?>> registry = new HashMap<>();
|
||||
|
||||
private static <L, R> void registerCase(String name, EntityOperator<L, R> operator) {
|
||||
registry.put(name.toLowerCase(Locale.getDefault()), operator);
|
||||
@@ -77,24 +77,25 @@ public abstract class EntityOperator<L, R> implements Serializable {
|
||||
}
|
||||
|
||||
public static <L, R> EntityComparisonOperator<L, R> lookupComparison(String name) {
|
||||
EntityOperator<?,?> operator = lookup(name);
|
||||
if (!(operator instanceof EntityComparisonOperator<?,?>)) {
|
||||
EntityOperator<?, ?> operator = lookup(name);
|
||||
if (!(operator instanceof EntityComparisonOperator<?, ?>)) {
|
||||
throw new IllegalArgumentException(name + " is not a comparison operator");
|
||||
}
|
||||
return UtilGenerics.cast(operator);
|
||||
}
|
||||
|
||||
public static EntityJoinOperator lookupJoin(String name) {
|
||||
EntityOperator<?,?> operator = lookup(name);
|
||||
EntityOperator<?, ?> operator = lookup(name);
|
||||
if (!(operator instanceof EntityJoinOperator)) {
|
||||
throw new IllegalArgumentException(name + " is not a join operator");
|
||||
}
|
||||
return UtilGenerics.cast(operator);
|
||||
}
|
||||
|
||||
public static final EntityComparisonOperator<?,?> EQUALS = new ComparableEntityComparisonOperator<Object>(ID_EQUALS, "=") {
|
||||
public static final EntityComparisonOperator<?, ?> EQUALS = new ComparableEntityComparisonOperator<Object>(ID_EQUALS, "=") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareEqual(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareEqual(lhs, rhs); }
|
||||
@Override
|
||||
protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, Datasource datasourceInfo) {
|
||||
if (rhs == null || rhs == GenericEntity.NULL_FIELD) {
|
||||
@@ -104,11 +105,14 @@ public abstract class EntityOperator<L, R> implements Serializable {
|
||||
}
|
||||
}
|
||||
};
|
||||
static { register("equals", EQUALS); }
|
||||
static { register("=", EQUALS); }
|
||||
public static final EntityComparisonOperator<?,?> NOT_EQUAL = new ComparableEntityComparisonOperator<Object>(ID_NOT_EQUAL, "<>") {
|
||||
static {
|
||||
register("equals", EQUALS); }
|
||||
static {
|
||||
register("=", EQUALS); }
|
||||
public static final EntityComparisonOperator<?, ?> NOT_EQUAL = new ComparableEntityComparisonOperator<Object>(ID_NOT_EQUAL, "<>") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareNotEqual(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareNotEqual(lhs, rhs); }
|
||||
@Override
|
||||
protected void makeRHSWhereString(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Object rhs, Datasource datasourceInfo) {
|
||||
if (rhs == null || rhs == GenericEntity.NULL_FIELD) {
|
||||
@@ -118,83 +122,126 @@ public abstract class EntityOperator<L, R> implements Serializable {
|
||||
}
|
||||
}
|
||||
};
|
||||
static { register("not-equal", NOT_EQUAL); }
|
||||
static { register("not-equals", NOT_EQUAL); }
|
||||
static { register("notEqual", NOT_EQUAL); }
|
||||
static { register("!=", NOT_EQUAL); }
|
||||
static { register("<>", NOT_EQUAL); }
|
||||
public static final EntityComparisonOperator<?,?> LESS_THAN = new ComparableEntityComparisonOperator<Object>(ID_LESS_THAN, "<") {
|
||||
static {
|
||||
register("not-equal", NOT_EQUAL); }
|
||||
static {
|
||||
register("not-equals", NOT_EQUAL); }
|
||||
static {
|
||||
register("notEqual", NOT_EQUAL); }
|
||||
static {
|
||||
register("!=", NOT_EQUAL); }
|
||||
static {
|
||||
register("<>", NOT_EQUAL); }
|
||||
public static final EntityComparisonOperator<?, ?> LESS_THAN = new ComparableEntityComparisonOperator<Object>(ID_LESS_THAN, "<") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareLessThan(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareLessThan(lhs, rhs); }
|
||||
};
|
||||
static { register("less", LESS_THAN); }
|
||||
static { register("less-than", LESS_THAN); }
|
||||
static { register("lessThan", LESS_THAN); }
|
||||
static { register("<", LESS_THAN); }
|
||||
public static final EntityComparisonOperator<?,?> GREATER_THAN = new ComparableEntityComparisonOperator<Object>(ID_GREATER_THAN, ">") {
|
||||
static {
|
||||
register("less", LESS_THAN); }
|
||||
static {
|
||||
register("less-than", LESS_THAN); }
|
||||
static {
|
||||
register("lessThan", LESS_THAN); }
|
||||
static {
|
||||
register("<", LESS_THAN); }
|
||||
public static final EntityComparisonOperator<?, ?> GREATER_THAN = new ComparableEntityComparisonOperator<Object>(ID_GREATER_THAN, ">") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThan(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareGreaterThan(lhs, rhs); }
|
||||
};
|
||||
static { register("greater", GREATER_THAN); }
|
||||
static { register("greater-than", GREATER_THAN); }
|
||||
static { register("greaterThan", GREATER_THAN); }
|
||||
static { register(">", GREATER_THAN); }
|
||||
public static final EntityComparisonOperator<?,?> LESS_THAN_EQUAL_TO = new ComparableEntityComparisonOperator<Object>(ID_LESS_THAN_EQUAL_TO, "<=") {
|
||||
static {
|
||||
register("greater", GREATER_THAN); }
|
||||
static {
|
||||
register("greater-than", GREATER_THAN); }
|
||||
static {
|
||||
register("greaterThan", GREATER_THAN); }
|
||||
static {
|
||||
register(">", GREATER_THAN); }
|
||||
public static final EntityComparisonOperator<?, ?> LESS_THAN_EQUAL_TO = new ComparableEntityComparisonOperator<Object>(ID_LESS_THAN_EQUAL_TO, "<=") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareLessThanEqualTo(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareLessThanEqualTo(lhs, rhs); }
|
||||
};
|
||||
static { register("less-equals", LESS_THAN_EQUAL_TO); }
|
||||
static { register("less-than-equal-to", LESS_THAN_EQUAL_TO); }
|
||||
static { register("lessThanEqualTo", LESS_THAN_EQUAL_TO); }
|
||||
static { register("<=", LESS_THAN_EQUAL_TO); }
|
||||
public static final EntityComparisonOperator<?,?> GREATER_THAN_EQUAL_TO = new ComparableEntityComparisonOperator<Object>(ID_GREATER_THAN_EQUAL_TO, ">=") {
|
||||
static {
|
||||
register("less-equals", LESS_THAN_EQUAL_TO); }
|
||||
static {
|
||||
register("less-than-equal-to", LESS_THAN_EQUAL_TO); }
|
||||
static {
|
||||
register("lessThanEqualTo", LESS_THAN_EQUAL_TO); }
|
||||
static {
|
||||
register("<=", LESS_THAN_EQUAL_TO); }
|
||||
public static final EntityComparisonOperator<?, ?> GREATER_THAN_EQUAL_TO = new ComparableEntityComparisonOperator<Object>(ID_GREATER_THAN_EQUAL_TO, ">=") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareGreaterThanEqualTo(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareGreaterThanEqualTo(lhs, rhs); }
|
||||
};
|
||||
static { register("greater-equals", GREATER_THAN_EQUAL_TO); }
|
||||
static { register("greater-than-equal-to", GREATER_THAN_EQUAL_TO); }
|
||||
static { register("greaterThanEqualTo", GREATER_THAN_EQUAL_TO); }
|
||||
static { register(">=", GREATER_THAN_EQUAL_TO); }
|
||||
public static final EntityComparisonOperator<?,?> IN = new CollectionEntityComparisonOperator<Object>(ID_IN, "IN") {
|
||||
static {
|
||||
register("greater-equals", GREATER_THAN_EQUAL_TO); }
|
||||
static {
|
||||
register("greater-than-equal-to", GREATER_THAN_EQUAL_TO); }
|
||||
static {
|
||||
register("greaterThanEqualTo", GREATER_THAN_EQUAL_TO); }
|
||||
static {
|
||||
register(">=", GREATER_THAN_EQUAL_TO); }
|
||||
public static final EntityComparisonOperator<?, ?> IN = new CollectionEntityComparisonOperator<Object>(ID_IN, "IN") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) {
|
||||
return EntityComparisonOperator.compareIn(lhs, rhs); }
|
||||
@Override
|
||||
protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Collection<Comparable<Object>> rhs, Datasource datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); }
|
||||
};
|
||||
static { register("in", IN); }
|
||||
public static final EntityComparisonOperator<?,?> BETWEEN = new CollectionEntityComparisonOperator<Object>(ID_BETWEEN, "BETWEEN") {
|
||||
static {
|
||||
register("in", IN); }
|
||||
public static final EntityComparisonOperator<?, ?> BETWEEN = new CollectionEntityComparisonOperator<Object>(ID_BETWEEN, "BETWEEN") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) { return EntityComparisonOperator.compareIn(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) {
|
||||
return EntityComparisonOperator.compareIn(lhs, rhs); }
|
||||
@Override
|
||||
protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Collection<Comparable<Object>> rhs, Datasource datasourceInfo) { appendRHSBetweenList(entityConditionParams, sb, field, rhs); }
|
||||
};
|
||||
static { register("between", BETWEEN); }
|
||||
public static final EntityComparisonOperator<?,?> NOT = new EntityComparisonOperator<Object, EntityCondition>(ID_NOT, "NOT") {
|
||||
static {
|
||||
register("between", BETWEEN); }
|
||||
public static final EntityComparisonOperator<?, ?> NOT = new EntityComparisonOperator<Object, EntityCondition>(ID_NOT, "NOT") {
|
||||
@Override
|
||||
public boolean compare(Object lhs, EntityCondition rhs) { throw new UnsupportedOperationException(); }
|
||||
public boolean compare(Object lhs, EntityCondition rhs) {
|
||||
throw new UnsupportedOperationException(); }
|
||||
};
|
||||
static { register("not", NOT); }
|
||||
static {
|
||||
register("not", NOT); }
|
||||
public static final EntityJoinOperator AND = new EntityJoinOperator(ID_AND, "AND", false);
|
||||
static { register("and", AND); }
|
||||
static {
|
||||
register("and", AND); }
|
||||
public static final EntityJoinOperator OR = new EntityJoinOperator(ID_OR, "OR", true);
|
||||
static { register("or", OR); }
|
||||
public static final EntityComparisonOperator<?,?> LIKE = new ComparableEntityComparisonOperator<Object>(ID_LIKE, "LIKE") {
|
||||
static {
|
||||
register("or", OR); }
|
||||
public static final EntityComparisonOperator<?, ?> LIKE = new ComparableEntityComparisonOperator<Object>(ID_LIKE, "LIKE") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareLike(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return EntityComparisonOperator.compareLike(lhs, rhs); }
|
||||
};
|
||||
static { register("like", LIKE); }
|
||||
public static final EntityComparisonOperator<?,?> NOT_LIKE = new ComparableEntityComparisonOperator<Object>(ID_NOT_LIKE, "NOT LIKE") {
|
||||
static {
|
||||
register("like", LIKE); }
|
||||
public static final EntityComparisonOperator<?, ?> NOT_LIKE = new ComparableEntityComparisonOperator<Object>(ID_NOT_LIKE, "NOT LIKE") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) { return !EntityComparisonOperator.compareLike(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Object rhs) {
|
||||
return !EntityComparisonOperator.compareLike(lhs, rhs);
|
||||
}
|
||||
};
|
||||
static { register("not-like", NOT_LIKE); }
|
||||
public static final EntityComparisonOperator<?,?> NOT_IN = new CollectionEntityComparisonOperator<Object>(ID_NOT_IN, "NOT IN") {
|
||||
static {
|
||||
register("not-like", NOT_LIKE);
|
||||
}
|
||||
public static final EntityComparisonOperator<?, ?> NOT_IN = new CollectionEntityComparisonOperator<Object>(ID_NOT_IN, "NOT IN") {
|
||||
@Override
|
||||
public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) { return !EntityComparisonOperator.compareIn(lhs, rhs); }
|
||||
public boolean compare(Comparable<Object> lhs, Collection<Comparable<Object>> rhs) {
|
||||
return !EntityComparisonOperator.compareIn(lhs, rhs);
|
||||
}
|
||||
@Override
|
||||
protected void makeRHSWhereStringValue(ModelEntity entity, List<EntityConditionParam> entityConditionParams, StringBuilder sb, ModelField field, Collection<Comparable<Object>> rhs, Datasource datasourceInfo) { appendRHSList(entityConditionParams, sb, field, rhs); }
|
||||
};
|
||||
static { register("not-in", NOT_IN); }
|
||||
static {
|
||||
register("not-in", NOT_IN);
|
||||
}
|
||||
|
||||
protected int idInt;
|
||||
protected String codeString;
|
||||
@@ -231,8 +278,8 @@ public abstract class EntityOperator<L, R> implements Serializable {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof EntityOperator<?,?>) {
|
||||
EntityOperator<?,?> otherOper = UtilGenerics.cast(obj);
|
||||
if (obj instanceof EntityOperator<?, ?>) {
|
||||
EntityOperator<?, ?> otherOper = UtilGenerics.cast(obj);
|
||||
return this.idInt == otherOper.idInt;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -137,14 +137,14 @@ public class OrderByItem implements Comparator<GenericEntity> {
|
||||
}
|
||||
EntityConditionValue value = EntityFieldValue.makeFieldValue(text);
|
||||
switch (caseSensitivity) {
|
||||
case UPPER:
|
||||
value = EntityFunction.UPPER(value);
|
||||
break;
|
||||
case LOWER:
|
||||
value = EntityFunction.LOWER(value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case UPPER:
|
||||
value = EntityFunction.UPPER(value);
|
||||
break;
|
||||
case LOWER:
|
||||
value = EntityFunction.LOWER(value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new OrderByItem(value, descending, nullsFirst);
|
||||
}
|
||||
|
||||
@@ -106,13 +106,14 @@ public class GenericDAO {
|
||||
ModelEntity modelEntity = entity.getModelEntity();
|
||||
|
||||
try (SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo)) {
|
||||
try {
|
||||
return singleInsert(entity, modelEntity, modelEntity.getFieldsUnmodifiable(), sqlP);
|
||||
} catch (GenericEntityException e) {
|
||||
sqlP.rollback();
|
||||
// no need to create nested, just throw original which will have all info: throw new GenericEntityException("Exception while inserting the following entity: " + entity.toString(), e);
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
return singleInsert(entity, modelEntity, modelEntity.getFieldsUnmodifiable(), sqlP);
|
||||
} catch (GenericEntityException e) {
|
||||
sqlP.rollback();
|
||||
// no need to create nested, just throw original which will have all info: throw new
|
||||
// GenericEntityException("Exception while inserting the following entity: " + entity.toString(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,13 +200,14 @@ public class GenericDAO {
|
||||
|
||||
private int customUpdate(GenericEntity entity, ModelEntity modelEntity, List<ModelField> fieldsToSave) throws GenericEntityException {
|
||||
try (SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo)) {
|
||||
try {
|
||||
return singleUpdate(entity, modelEntity, fieldsToSave, sqlP);
|
||||
} catch (GenericEntityException e) {
|
||||
sqlP.rollback();
|
||||
// no need to create nested, just throw original which will have all info: throw new GenericEntityException("Exception while updating the following entity: " + entity.toString(), e);
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
return singleUpdate(entity, modelEntity, fieldsToSave, sqlP);
|
||||
} catch (GenericEntityException e) {
|
||||
sqlP.rollback();
|
||||
// no need to create nested, just throw original which will have all info: throw new
|
||||
// GenericEntityException("Exception while updating the following entity: " + entity.toString(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,23 +503,23 @@ public class GenericDAO {
|
||||
sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, modelFieldTypeReader, datasource));
|
||||
sqlBuffer.append(SqlJdbcUtil.makeWhereClause(modelEntity, modelEntity.getPkFieldsUnmodifiable(), entity, "AND", datasource.getJoinStyle()));
|
||||
|
||||
sqlP.prepareStatement(sqlBuffer.toString(), true, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||
SqlJdbcUtil.setPkValues(sqlP, modelEntity, entity, modelFieldTypeReader);
|
||||
sqlP.executeQuery();
|
||||
sqlP.prepareStatement(sqlBuffer.toString(), true, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||
SqlJdbcUtil.setPkValues(sqlP, modelEntity, entity, modelFieldTypeReader);
|
||||
sqlP.executeQuery();
|
||||
|
||||
if (sqlP.next()) {
|
||||
int idx = 1;
|
||||
Iterator<ModelField> nopkIter = modelEntity.getNopksIterator();
|
||||
while (nopkIter.hasNext()) {
|
||||
ModelField curField = nopkIter.next();
|
||||
SqlJdbcUtil.getValue(sqlP.getResultSet(), idx, curField, entity, modelFieldTypeReader);
|
||||
idx++;
|
||||
}
|
||||
if (sqlP.next()) {
|
||||
int idx = 1;
|
||||
Iterator<ModelField> nopkIter = modelEntity.getNopksIterator();
|
||||
while (nopkIter.hasNext()) {
|
||||
ModelField curField = nopkIter.next();
|
||||
SqlJdbcUtil.getValue(sqlP.getResultSet(), idx, curField, entity, modelFieldTypeReader);
|
||||
idx++;
|
||||
}
|
||||
|
||||
entity.synchronizedWithDatasource();
|
||||
} else {
|
||||
// Debug.logWarning("[GenericDAO.select]: select failed, result set was empty for entity: " + entity.toString(), MODULE);
|
||||
throw new GenericEntityNotFoundException("Result set was empty for entity: " + entity.toString());
|
||||
entity.synchronizedWithDatasource();
|
||||
} else {
|
||||
// Debug.logWarning("[GenericDAO.select]: select failed, result set was empty for entity: " + entity.toString(), MODULE);
|
||||
throw new GenericEntityNotFoundException("Result set was empty for entity: " + entity.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1074,40 +1076,38 @@ public class GenericDAO {
|
||||
try (SQLProcessor sqlP = new SQLProcessor(delegator, helperInfo)) {
|
||||
sqlP.prepareStatement(sql, findOptions.getSpecifyTypeAndConcur(), findOptions.getResultSetType(),
|
||||
findOptions.getResultSetConcurrency(), findOptions.getFetchSize(), findOptions.getMaxRows());
|
||||
if (verboseOn) {
|
||||
// put this inside an if statement so that we don't have to generate the string when not used...
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Setting the whereEntityConditionParams: " + whereEntityConditionParams, MODULE);
|
||||
if (verboseOn) {
|
||||
// put this inside an if statement so that we don't have to generate the string when not used...
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Setting the whereEntityConditionParams: " + whereEntityConditionParams, MODULE);
|
||||
}
|
||||
}
|
||||
}
|
||||
// set all of the values from the Where EntityCondition
|
||||
for (EntityConditionParam whereEntityConditionParam: whereEntityConditionParams) {
|
||||
SqlJdbcUtil.setValue(sqlP, whereEntityConditionParam.getModelField(), modelEntity.getEntityName(), whereEntityConditionParam.getFieldValue(), modelFieldTypeReader);
|
||||
}
|
||||
if (verboseOn) {
|
||||
// put this inside an if statement so that we don't have to generate the string when not used...
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Setting the havingEntityConditionParams: " + havingEntityConditionParams, MODULE);
|
||||
// set all of the values from the Where EntityCondition
|
||||
for (EntityConditionParam whereEntityConditionParam: whereEntityConditionParams) {
|
||||
SqlJdbcUtil.setValue(sqlP, whereEntityConditionParam.getModelField(), modelEntity.getEntityName(), whereEntityConditionParam.getFieldValue(), modelFieldTypeReader);
|
||||
}
|
||||
}
|
||||
// set all of the values from the Having EntityCondition
|
||||
for (EntityConditionParam havingEntityConditionParam: havingEntityConditionParams) {
|
||||
SqlJdbcUtil.setValue(sqlP, havingEntityConditionParam.getModelField(), modelEntity.getEntityName(), havingEntityConditionParam.getFieldValue(), modelFieldTypeReader);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
sqlP.executeQuery();
|
||||
long count = 0;
|
||||
ResultSet resultSet = sqlP.getResultSet();
|
||||
if (resultSet.next()) {
|
||||
count = resultSet.getLong(1);
|
||||
if (verboseOn) {
|
||||
// put this inside an if statement so that we don't have to generate the string when not used...
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Setting the havingEntityConditionParams: " + havingEntityConditionParams, MODULE);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
// set all of the values from the Having EntityCondition
|
||||
for (EntityConditionParam havingEntityConditionParam: havingEntityConditionParams) {
|
||||
SqlJdbcUtil.setValue(sqlP, havingEntityConditionParam.getModelField(), modelEntity.getEntityName(), havingEntityConditionParam.getFieldValue(), modelFieldTypeReader);
|
||||
}
|
||||
try {
|
||||
sqlP.executeQuery();
|
||||
long count = 0;
|
||||
ResultSet resultSet = sqlP.getResultSet();
|
||||
if (resultSet.next()) {
|
||||
count = resultSet.getLong(1);
|
||||
}
|
||||
return count;
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new GenericDataSourceException("Error getting count value", e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new GenericDataSourceException("Error getting count value", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,13 +1117,12 @@ public class GenericDAO {
|
||||
|
||||
public int delete(GenericEntity entity) throws GenericEntityException {
|
||||
try (SQLProcessor sqlP = new SQLProcessor(entity.getDelegator(), helperInfo)) {
|
||||
|
||||
try {
|
||||
return delete(entity, sqlP);
|
||||
} catch (GenericDataSourceException e) {
|
||||
sqlP.rollback();
|
||||
throw new GenericDataSourceException("Exception while deleting the following entity: " + entity.toString(), e);
|
||||
}
|
||||
try {
|
||||
return delete(entity, sqlP);
|
||||
} catch (GenericDataSourceException e) {
|
||||
sqlP.rollback();
|
||||
throw new GenericDataSourceException("Exception while deleting the following entity: " + entity.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1148,12 +1147,12 @@ public class GenericDAO {
|
||||
|
||||
public int deleteByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
|
||||
try (SQLProcessor sqlP = new SQLProcessor(delegator, helperInfo)) {
|
||||
try {
|
||||
return deleteByCondition(modelEntity, condition, sqlP);
|
||||
} catch (GenericDataSourceException e) {
|
||||
sqlP.rollback();
|
||||
throw new GenericDataSourceException("Generic Entity Exception occurred in deleteByCondition", e);
|
||||
}
|
||||
try {
|
||||
return deleteByCondition(modelEntity, condition, sqlP);
|
||||
} catch (GenericDataSourceException e) {
|
||||
sqlP.rollback();
|
||||
throw new GenericDataSourceException("Generic Entity Exception occurred in deleteByCondition", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1170,10 +1169,9 @@ public class GenericDAO {
|
||||
if (UtilValidate.isNotEmpty(whereCondition)) {
|
||||
sql.append(" WHERE ").append(whereCondition);
|
||||
}
|
||||
sqlP.prepareStatement(sql.toString());
|
||||
|
||||
sqlP.prepareStatement(sql.toString());
|
||||
|
||||
return sqlP.executeUpdate();
|
||||
return sqlP.executeUpdate();
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
@@ -154,7 +154,7 @@ public final class EntityFinderUtil {
|
||||
@SuppressWarnings("serial")
|
||||
public static final class ConditionExpr implements Condition {
|
||||
private final String fieldName;
|
||||
private final EntityOperator<?,?> operator;
|
||||
private final EntityOperator<?, ?> operator;
|
||||
private final FlexibleMapAccessor<Object> envNameAcsr;
|
||||
private final FlexibleStringExpander valueExdr;
|
||||
private final FlexibleStringExpander ignoreExdr;
|
||||
@@ -239,27 +239,27 @@ public final class EntityFinderUtil {
|
||||
// this makes more sense logically, but if anyone ever needs it to not behave this way we should add an "or-null" attribute that is true by default
|
||||
if (ignoreCase) {
|
||||
return EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), EntityFunction.UPPER(value)),
|
||||
EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), UtilGenerics.<EntityComparisonOperator<?, ?>>cast(operator), EntityFunction.UPPER(value)),
|
||||
EntityOperator.OR,
|
||||
EntityCondition.makeCondition(fieldName, EntityOperator.EQUALS, null));
|
||||
}
|
||||
return EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition(fieldName, UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), value),
|
||||
EntityCondition.makeCondition(fieldName, UtilGenerics.<EntityComparisonOperator<?, ?>>cast(operator), value),
|
||||
EntityOperator.OR,
|
||||
EntityCondition.makeCondition(fieldName, EntityOperator.EQUALS, null));
|
||||
}
|
||||
if (ignoreCase) {
|
||||
// use the stuff to upper case both sides
|
||||
return EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), EntityFunction.UPPER(value));
|
||||
return EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), UtilGenerics.<EntityComparisonOperator<?, ?>>cast(operator), EntityFunction.UPPER(value));
|
||||
}
|
||||
return EntityCondition.makeCondition(fieldName, UtilGenerics.<EntityComparisonOperator<?,?>>cast(operator), value);
|
||||
return EntityCondition.makeCondition(fieldName, UtilGenerics.<EntityComparisonOperator<?, ?>>cast(operator), value);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static final class ConditionList implements Condition {
|
||||
private final List<Condition> conditionList;
|
||||
private final EntityOperator<?,?> operator;
|
||||
private final EntityOperator<?, ?> operator;
|
||||
|
||||
public ConditionList(Element conditionListElement) {
|
||||
String operatorAttribute = conditionListElement.getAttribute("combine");
|
||||
|
||||
@@ -576,8 +576,7 @@ public final class SqlJdbcUtil {
|
||||
while (curField.getEncryptMethod().isEncrypted() && model instanceof ModelViewEntity) {
|
||||
ModelViewEntity modelView = (ModelViewEntity) model;
|
||||
String entityName = modelView.getAliasedEntity(
|
||||
modelView.getAlias(curField.getName()).getEntityAlias(), entity.getDelegator().getModelReader()
|
||||
).getEntityName();
|
||||
modelView.getAlias(curField.getName()).getEntityAlias(), entity.getDelegator().getModelReader()).getEntityName();
|
||||
model = entity.getDelegator().getModelEntity(entityName);
|
||||
}
|
||||
String encryptionKeyName = model.getEntityName();
|
||||
@@ -877,11 +876,11 @@ public final class SqlJdbcUtil {
|
||||
}
|
||||
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("type of field " + entityName + "." + modelField.getName() +
|
||||
" is " + fieldClassName + ", was expecting " + mft.getJavaType() + "; this may " +
|
||||
"indicate an error in the configuration or in the class, and may result " +
|
||||
"in an SQL-Java data conversion error. Will use the real field type: " +
|
||||
fieldClassName + ", not the definition.", MODULE);
|
||||
Debug.logVerbose("type of field " + entityName + "." + modelField.getName()
|
||||
+ " is " + fieldClassName + ", was expecting " + mft.getJavaType() + "; this may "
|
||||
+ "indicate an error in the configuration or in the class, and may result "
|
||||
+ "in an SQL-Java data conversion error. Will use the real field type: "
|
||||
+ fieldClassName + ", not the definition.", MODULE);
|
||||
}
|
||||
fieldType = fieldClassName;
|
||||
}
|
||||
|
||||
@@ -233,11 +233,11 @@ public class XmlSerializer {
|
||||
}
|
||||
|
||||
Element element = document.createElement(elementName);
|
||||
Map<?,?> value = UtilGenerics.cast(object);
|
||||
Map<?, ?> value = UtilGenerics.cast(object);
|
||||
Iterator<Map.Entry<?, ?>> iter = UtilGenerics.cast(value.entrySet().iterator());
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<?,?> entry = iter.next();
|
||||
Map.Entry<?, ?> entry = iter.next();
|
||||
|
||||
Element entryElement = document.createElement("map-Entry");
|
||||
|
||||
|
||||
+1
-2
@@ -130,8 +130,7 @@ public class EntityCryptoTestSuite extends EntityTestCase {
|
||||
return EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition("testingCryptoTypeId", EntityOperator.IN, UtilMisc.toList("SUB_SELECT_1", "SUB_SELECT_3")),
|
||||
EntityOperator.AND,
|
||||
EntityCondition.makeCondition("encryptedValue", EntityOperator.EQUALS, nanoTime)
|
||||
);
|
||||
EntityCondition.makeCondition("encryptedValue", EntityOperator.EQUALS, nanoTime));
|
||||
}
|
||||
|
||||
protected EntityConditionSubSelect makeSubSelect(String nanoTime) {
|
||||
|
||||
@@ -381,8 +381,7 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
for (GenericValue node: nodeLevel1) {
|
||||
GenericValue testing = delegator.makeValue("Testing",
|
||||
"testingId", delegator.getNextSeqId("Testing"),
|
||||
"testingTypeId", "TEST-TREE-1"
|
||||
);
|
||||
"testingTypeId", "TEST-TREE-1");
|
||||
testing.put("testingName", "leaf-#" + node.getString("testingNodeId"));
|
||||
testing.put("description", "level1 leaf");
|
||||
testing.put("comments", "No-comments");
|
||||
@@ -392,8 +391,7 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
newValues.add(testing);
|
||||
GenericValue member = delegator.makeValue("TestingNodeMember",
|
||||
"testingNodeId", node.get("testingNodeId"),
|
||||
"testingId", testing.get("testingId")
|
||||
);
|
||||
"testingId", testing.get("testingId"));
|
||||
|
||||
member.put("fromDate", now);
|
||||
member.put("thruDate", UtilDateTime.getNextDayStart(now));
|
||||
@@ -418,14 +416,12 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
for (GenericValue node: EntityQuery.use(delegator)
|
||||
.from("TestingNode")
|
||||
.where(EntityCondition.makeCondition("description", EntityOperator.LIKE, descriptionPrefix + "%"))
|
||||
.queryList()
|
||||
) {
|
||||
.queryList()) {
|
||||
if (i % 2 == 0) {
|
||||
GenericValue testing = delegator.create("Testing", "testingId", descriptionPrefix + ":" + node.get("testingNodeId"), "testingTypeId", typeId, "description", node.get("description"));
|
||||
GenericValue member = delegator.makeValue("TestingNodeMember",
|
||||
"testingNodeId", node.get("testingNodeId"),
|
||||
"testingId", testing.get("testingId")
|
||||
);
|
||||
"testingId", testing.get("testingId"));
|
||||
|
||||
member.put("fromDate", now);
|
||||
member.put("thruDate", UtilDateTime.getNextDayStart(now));
|
||||
@@ -446,8 +442,7 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
EntityCondition isNodeWithMember = EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition("testingId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD),
|
||||
EntityOperator.AND,
|
||||
EntityCondition.makeCondition("description", EntityOperator.LIKE, "count-views:%")
|
||||
);
|
||||
EntityCondition.makeCondition("description", EntityOperator.LIKE, "count-views:%"));
|
||||
List<GenericValue> nodeWithMembers = EntityQuery.use(delegator).from("TestingNodeAndMember").where(isNodeWithMember).queryList();
|
||||
|
||||
for (GenericValue v: nodeWithMembers) {
|
||||
@@ -645,8 +640,7 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
EntityCondition isRoot = EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition("description", EntityOperator.LIKE, "remove-by-pk:%"),
|
||||
EntityOperator.AND,
|
||||
EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD)
|
||||
);
|
||||
EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD));
|
||||
List<GenericValue> rootValues = EntityQuery.use(delegator).select("testingNodeId").from("TestingNode").where(isRoot).queryList();
|
||||
|
||||
for (GenericValue value: rootValues) {
|
||||
|
||||
+23
-23
@@ -462,7 +462,7 @@ public final class TransactionUtil implements Status {
|
||||
if (tm != null && tm.getStatus() == STATUS_ACTIVE) {
|
||||
Transaction tx = tm.getTransaction();
|
||||
if (tx != null) {
|
||||
tx.enlistResource(resource);
|
||||
tx.enlistResource(resource);
|
||||
}
|
||||
}
|
||||
} catch (RollbackException e) {
|
||||
@@ -489,28 +489,28 @@ public final class TransactionUtil implements Status {
|
||||
* STATUS_ROLLING_BACK 9
|
||||
*/
|
||||
switch (state) {
|
||||
case Status.STATUS_ACTIVE:
|
||||
return "Transaction Active (" + state + ")";
|
||||
case Status.STATUS_COMMITTED:
|
||||
return "Transaction Committed (" + state + ")";
|
||||
case Status.STATUS_COMMITTING:
|
||||
return "Transaction Committing (" + state + ")";
|
||||
case Status.STATUS_MARKED_ROLLBACK:
|
||||
return "Transaction Marked Rollback (" + state + ")";
|
||||
case Status.STATUS_NO_TRANSACTION:
|
||||
return "No Transaction (" + state + ")";
|
||||
case Status.STATUS_PREPARED:
|
||||
return "Transaction Prepared (" + state + ")";
|
||||
case Status.STATUS_PREPARING:
|
||||
return "Transaction Preparing (" + state + ")";
|
||||
case Status.STATUS_ROLLEDBACK:
|
||||
return "Transaction Rolledback (" + state + ")";
|
||||
case Status.STATUS_ROLLING_BACK:
|
||||
return "Transaction Rolling Back (" + state + ")";
|
||||
case Status.STATUS_UNKNOWN:
|
||||
return "Transaction Status Unknown (" + state + ")";
|
||||
default:
|
||||
return "Not a valid state code (" + state + ")";
|
||||
case Status.STATUS_ACTIVE:
|
||||
return "Transaction Active (" + state + ")";
|
||||
case Status.STATUS_COMMITTED:
|
||||
return "Transaction Committed (" + state + ")";
|
||||
case Status.STATUS_COMMITTING:
|
||||
return "Transaction Committing (" + state + ")";
|
||||
case Status.STATUS_MARKED_ROLLBACK:
|
||||
return "Transaction Marked Rollback (" + state + ")";
|
||||
case Status.STATUS_NO_TRANSACTION:
|
||||
return "No Transaction (" + state + ")";
|
||||
case Status.STATUS_PREPARED:
|
||||
return "Transaction Prepared (" + state + ")";
|
||||
case Status.STATUS_PREPARING:
|
||||
return "Transaction Preparing (" + state + ")";
|
||||
case Status.STATUS_ROLLEDBACK:
|
||||
return "Transaction Rolledback (" + state + ")";
|
||||
case Status.STATUS_ROLLING_BACK:
|
||||
return "Transaction Rolling Back (" + state + ")";
|
||||
case Status.STATUS_UNKNOWN:
|
||||
return "Transaction Status Unknown (" + state + ")";
|
||||
default:
|
||||
return "Not a valid state code (" + state + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
import org.apache.ofbiz.base.util.Debug;
|
||||
import org.apache.ofbiz.entity.GenericEntityException;
|
||||
import org.apache.ofbiz.entity.GenericValue;
|
||||
import org.apache.ofbiz.entity.util.EntityQuery;
|
||||
|
||||
public class EntityBatchIterator implements Iterator<GenericValue> {
|
||||
public static final String MODULE = EntityBatchIterator.class.getName();
|
||||
|
||||
@@ -276,20 +276,20 @@ public final class EntityCrypto {
|
||||
@Override
|
||||
protected byte[] decryptValue(byte[] key, EncryptMethod encryptMethod, String encryptedString) throws GeneralException {
|
||||
switch (encryptMethod) {
|
||||
case SALT:
|
||||
return saltedCipherService.decrypt(Base64.decodeBase64(encryptedString), key).getBytes();
|
||||
default:
|
||||
return cipherService.decrypt(Base64.decodeBase64(encryptedString), key).getBytes();
|
||||
case SALT:
|
||||
return saltedCipherService.decrypt(Base64.decodeBase64(encryptedString), key).getBytes();
|
||||
default:
|
||||
return cipherService.decrypt(Base64.decodeBase64(encryptedString), key).getBytes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String encryptValue(EncryptMethod encryptMethod, byte[] key, byte[] objBytes) throws GeneralException {
|
||||
switch (encryptMethod) {
|
||||
case SALT:
|
||||
return saltedCipherService.encrypt(objBytes, key).toBase64();
|
||||
default:
|
||||
return cipherService.encrypt(objBytes, key).toBase64();
|
||||
case SALT:
|
||||
return saltedCipherService.encrypt(objBytes, key).toBase64();
|
||||
default:
|
||||
return cipherService.encrypt(objBytes, key).toBase64();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,15 +413,15 @@ public final class EntityCrypto {
|
||||
protected String encryptValue(EncryptMethod encryptMethod, byte[] key, byte[] objBytes) throws GeneralException {
|
||||
byte[] saltBytes;
|
||||
switch (encryptMethod) {
|
||||
case SALT:
|
||||
Random random = new SecureRandom();
|
||||
// random length 5-16
|
||||
saltBytes = new byte[5 + random.nextInt(11)];
|
||||
random.nextBytes(saltBytes);
|
||||
break;
|
||||
default:
|
||||
saltBytes = new byte[0];
|
||||
break;
|
||||
case SALT:
|
||||
Random random = new SecureRandom();
|
||||
// random length 5-16
|
||||
saltBytes = new byte[5 + random.nextInt(11)];
|
||||
random.nextBytes(saltBytes);
|
||||
break;
|
||||
default:
|
||||
saltBytes = new byte[0];
|
||||
break;
|
||||
}
|
||||
byte[] allBytes = new byte[1 + saltBytes.length + objBytes.length];
|
||||
allBytes[0] = (byte) saltBytes.length;
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class EntityTypeUtil {
|
||||
try {
|
||||
childTypeValue = EntityQuery.use(delegator).from(entityName).where(primaryKey, childType).cache(true).queryOne();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError("Error finding "+entityName+" record for type "+childType, MODULE);
|
||||
Debug.logError("Error finding " + entityName + " record for type " + childType, MODULE);
|
||||
}
|
||||
if (childTypeValue != null) {
|
||||
if (parentType.equals(childTypeValue.getString(primaryKey))) return true;
|
||||
|
||||
Reference in New Issue
Block a user