Package com.atlassian.jira.entity
Class EntityUtils
java.lang.Object
com.atlassian.jira.entity.EntityUtils
Has some utility methods for working with Entity Engine.
This originally lived in atlassian-core, but got moved to JIRA in v4.3 and moved to the com.atlassian.jira package in v5.1
- Since:
- v5.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> List<org.ofbiz.core.entity.GenericValue> convertToGenericValues(EntityFactory<E> entityFactory, List<E> entityList) static org.ofbiz.core.entity.GenericValuecreateValue(String entityName, Map<String, Object> fields) Create a new entity.static StringgetNextStringId(String entityName) Calculate a new entity ID (by basically taking one more than the max integer that exists).static booleanidentical(org.ofbiz.core.entity.GenericValue v1, org.ofbiz.core.entity.GenericValue v2) Compare two GenericValues based on their content.static voidinternStringFieldValue(org.ofbiz.core.entity.GenericValue value, String fieldName) Forcibly interns the contents of a String field in a GenericValue.
-
Constructor Details
-
EntityUtils
public EntityUtils()
-
-
Method Details
-
createValue
public static org.ofbiz.core.entity.GenericValue createValue(String entityName, Map<String, Object> fields) Create a new entity.If there is no "id" in the parameter list, one is created using the entity sequence.
- Parameters:
entityName- the entity name.fields- field values- Returns:
- The new GenericValue.
- Throws:
DataAccessException- if an error occurs in the Database layer- See Also:
-
identical
public static boolean identical(org.ofbiz.core.entity.GenericValue v1, org.ofbiz.core.entity.GenericValue v2) Compare two GenericValues based on their content.This method will check the keys and values of both GenericValues.
There is only a single difference between this method and GenericValue.equals(gv2), that is that if one GV has no key of a certain type, and the other has a null value for that key, they are still deemed to be identical (as GenericValue.get(key) always returns null if the key exists or not).
- Parameters:
v1- the first GenericValuev2- the second GenericValue- Returns:
- true if the issues are the same, false if they are different
-
getNextStringId
Calculate a new entity ID (by basically taking one more than the max integer that exists). If there are string IDs here, they will not be affected.- Parameters:
entityName- The entity name- Returns:
- the next ID for a String ID column.
-
internStringFieldValue
public static void internStringFieldValue(org.ofbiz.core.entity.GenericValue value, String fieldName) Forcibly interns the contents of a String field in a GenericValue. This is a horrible, hackish thing to do and should be avoided if at all possible. However, if you are required to support an API that still usesGenericValues and need to cache them, it may make sense to use this method to avoid keeping excessive duplicate copies of their values.Caveats:
- This should be considered both a smell and a last resort.
- GenericValue is mutable and not thread-safe. Caching them is less than ideal. Consider doing something else if you can.
-
convertToGenericValues
public static <E> List<org.ofbiz.core.entity.GenericValue> convertToGenericValues(EntityFactory<E> entityFactory, List<E> entityList)
-