Improved: Use the ‘@Override’ annotation

(OFBIZ-10939)

The ‘@Override’ annotation helps readers understand that the method at
hand is overriding a super class or implementing an interface.
Additionally it allows the compiler to check if the methods annotated
with ‘@Override’ are actually implementing an abstract method.

Using that annotation makes ‘@see foo.bar.ParentClass#myMethod’
comments useless, so those they have been removed for the newly
annotated methods.

Thanks Jacques Le Roux and Swapnil M Mane for acknowledging the commit.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mathieu Lirzin
2019-04-27 19:34:25 +00:00
parent 948d73946e
commit b37e315aef
169 changed files with 925 additions and 249 deletions
@@ -71,6 +71,7 @@ public abstract class DelegatorFactory implements Factory<Delegator, String> {
this.delegatorName = delegatorName;
}
@Override
public Delegator call() throws ClassNotFoundException {
try {
Delegator delegator = UtilObject.getObjectFromFactory(DelegatorFactory.class, delegatorName);
@@ -27,6 +27,7 @@ public class DelegatorFactoryImpl extends DelegatorFactory {
public static final String module = DelegatorFactoryImpl.class.getName();
// TODO: this method should propagate the GenericEntityException
@Override
public Delegator getInstance(String delegatorName) {
if (Debug.infoOn()) {
Debug.logInfo("Creating new delegator [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", module);
@@ -2223,17 +2223,12 @@ public class GenericDelegator implements Delegator {
return nextSeqLong.toString();
}
/* (non-Javadoc)
* @see org.apache.ofbiz.entity.Delegator#getNextSeqIdLong(java.lang.String)
*/
@Override
public Long getNextSeqIdLong(String seqName) {
return this.getNextSeqIdLong(seqName, 1);
}
/* (non-Javadoc)
* @see org.apache.ofbiz.entity.Delegator#getNextSeqIdLong(java.lang.String, long)
*/
@Override
public Long getNextSeqIdLong(String seqName, long staggerMax) {
try {
SequenceUtil sequencer = this.AtomicRefSequencer.get();
@@ -796,6 +796,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
* @return If the corresponding resource is found and contains a key as described above, then that
* property value is returned; otherwise returns the field value
*/
@Override
public Object get(String name, Locale locale) {
return get(name, null, locale);
}
@@ -1431,6 +1432,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
*@param that Object to compare this to
*@return int representing the result of the comparison (-1,0, or 1)
*/
@Override
public int compareTo(GenericEntity that) {
// if null, it will push to the beginning
if (that == null) {
@@ -1482,52 +1484,62 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
return newEntity;
}
// ---- Methods added to implement the Map interface: ----
@Override
public Object remove(Object key) {
return this.fields.remove(key);
}
@Override
public boolean containsKey(Object key) {
return this.fields.containsKey(key);
}
@Override
public java.util.Set<Map.Entry<String, Object>> entrySet() {
return Collections.unmodifiableMap(this.fields).entrySet();
}
@Override
public Object put(String key, Object value) {
return this.set(key, value, true);
}
@Override
public void putAll(java.util.Map<? extends String, ? extends Object> map) {
this.setFields(map);
}
@Override
public void clear() {
this.fields.clear();
}
@Override
public Object get(Object key) {
return this.get((String) key);
}
@Override
public java.util.Set<String> keySet() {
return Collections.unmodifiableSet(this.fields.keySet());
}
@Override
public boolean isEmpty() {
return this.fields.isEmpty();
}
@Override
public java.util.Collection<Object> values() {
return Collections.unmodifiableMap(this.fields).values();
}
@Override
public boolean containsValue(Object value) {
return this.fields.containsValue(value);
}
@Override
public int size() {
return this.fields.size();
}
@@ -1679,6 +1691,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
return this == o;
}
@Override
public int compareTo(NullField other) {
return equals(other) ? 0 : -1;
}
@@ -44,29 +44,36 @@ public class EntityConditionBuilder extends BuilderSupport {
this.condition = condition;
}
@Override
public boolean isEmpty() {
return condition.isEmpty();
}
@Override
public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo) {
return condition.makeWhereString(modelEntity, entityConditionParams, datasourceInfo);
}
@Override
public void checkCondition(ModelEntity modelEntity) throws GenericModelException {
condition.checkCondition(modelEntity);
}
@Override
public boolean mapMatches(Delegator delegator, Map<String, ? extends Object> map) {
return condition.mapMatches(delegator, map);
}
@Override
public EntityCondition freeze() {
return condition.freeze();
}
@Override
public int hashCode() {
return condition.hashCode();
}
@Override
public boolean equals(Object obj) {
return condition.equals(obj);
}
@@ -66,6 +66,7 @@ public abstract class EntityFunction<T extends Comparable<?>> extends EntityCond
*/
public static class LENGTH extends EntityFunctionSingle<Integer> {
public static final Fetcher<Integer> FETCHER = new Fetcher<Integer>() {
@Override
public Integer getValue(Object value) { return value.toString().length(); }
};
@@ -80,6 +81,7 @@ public abstract class EntityFunction<T extends Comparable<?>> extends EntityCond
*/
public static class TRIM extends EntityFunctionSingle<String> {
public static final Fetcher<String> FETCHER = new Fetcher<String>() {
@Override
public String getValue(Object value) { return value.toString().trim(); }
};
@@ -94,6 +96,7 @@ public abstract class EntityFunction<T extends Comparable<?>> extends EntityCond
*/
public static class UPPER extends EntityFunctionSingle<String> {
public static final Fetcher<String> FETCHER = new Fetcher<String>() {
@Override
public String getValue(Object value) { return value.toString().toUpperCase(Locale.getDefault()); }
};
@@ -108,6 +111,7 @@ public abstract class EntityFunction<T extends Comparable<?>> extends EntityCond
*/
public static class LOWER extends EntityFunctionSingle<String> {
public static final Fetcher<String> FETCHER = new Fetcher<String>() {
@Override
public String getValue(Object value) { return value.toString().toLowerCase(Locale.getDefault()); }
};
@@ -295,6 +295,7 @@ public abstract class EntityOperator<L, R> implements Serializable {
public abstract EntityCondition freeze(L lhs, R rhs);
public static final Comparable<?> WILDCARD = new Comparable<Object>() {
@Override
public int compareTo(Object obj) {
if (obj != WILDCARD) {
throw new ClassCastException();
@@ -153,6 +153,7 @@ public class OrderByItem implements Comparator<GenericEntity> {
value.validateSql(modelEntity);
}
@Override
public int compare(GenericEntity obj1, GenericEntity obj2) {
Comparable<Object> value1 = UtilGenerics.cast(value.getValue(obj1));
Object value2 = value.getValue(obj2);
@@ -96,6 +96,7 @@ public class OrderByList implements Comparator<GenericEntity> {
}
}
@Override
public int compare(GenericEntity entity1, GenericEntity entity2) {
int result = 0;
for (OrderByItem orderByItem: orderByList) {
@@ -59,6 +59,7 @@ public class DBCPConnectionFactory implements ConnectionFactory {
protected static final ConcurrentHashMap<String, DebugManagedDataSource<? extends Connection>> dsCache =
new ConcurrentHashMap<>();
@Override
public Connection getConnection(GenericHelperInfo helperInfo, JdbcElement abstractJdbc) throws SQLException, GenericEntityException {
String cacheKey = helperInfo.getHelperFullName();
DebugManagedDataSource<? extends Connection> mds = dsCache.get(cacheKey);
@@ -159,6 +160,7 @@ public class DBCPConnectionFactory implements ConnectionFactory {
return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection());
}
@Override
public void closeAll() {
// no methods on the pool to shutdown; so just clearing for GC
dsCache.clear();
@@ -51,6 +51,7 @@ public class GenericHelperDAO implements GenericHelper {
genericDAO = GenericDAO.getGenericDAO(helperInfo);
}
@Override
public String getHelperName() {
return this.helperInfo.getHelperFullName();
}
@@ -58,6 +59,7 @@ public class GenericHelperDAO implements GenericHelper {
/** Creates a Entity in the form of a GenericValue and write it to the database
*@return GenericValue instance containing the new instance
*/
@Override
public GenericValue create(GenericValue value) throws GenericEntityException {
if (value == null) {
return null;
@@ -71,6 +73,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param primaryKey The primary key to find by.
*@return The GenericValue corresponding to the primaryKey
*/
@Override
public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException {
if (primaryKey == null) {
return null;
@@ -86,6 +89,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param keys The keys, or names, of the values to retrieve; only these values will be retrieved
*@return The GenericValue corresponding to the primaryKey
*/
@Override
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException {
if (primaryKey == null) {
return null;
@@ -102,6 +106,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param primaryKeys A List of primary keys to find by.
*@return List of GenericValue objects corresponding to the passed primaryKey objects
*/
@Override
public List<GenericValue> findAllByPrimaryKeys(List<GenericPK> primaryKeys) throws GenericEntityException {
if (primaryKeys == null) return null;
List<GenericValue> results = new LinkedList<>();
@@ -118,6 +123,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param primaryKey The primary key of the entity to remove.
*@return int representing number of rows effected by this operation
*/
@Override
public int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException {
if (primaryKey == null) return 0;
if (Debug.verboseOn()) Debug.logVerbose("Removing GenericPK: " + primaryKey.toString(), module);
@@ -135,17 +141,20 @@ public class GenericHelperDAO implements GenericHelper {
* DONE WITH IT (preferably in a finally block),
* AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION.
*/
@Override
public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
throws GenericEntityException {
return genericDAO.selectListIteratorByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
}
@Override
public List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne,
ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException {
return genericDAO.selectByMultiRelation(value, modelRelationOne, modelEntityOne, modelRelationTwo, modelEntityTwo, orderBy);
}
@Override
public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
return genericDAO.selectCountByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
}
@@ -155,6 +164,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param condition The condition that restricts the list of removed values
*@return int representing number of rows effected by this operation
*/
@Override
public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
if (modelEntity == null || condition == null) {
return 0;
@@ -166,6 +176,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param value GenericValue instance containing the entity
*@return int representing number of rows effected by this operation
*/
@Override
public int store(GenericValue value) throws GenericEntityException {
if (value == null) {
return 0;
@@ -180,6 +191,7 @@ public class GenericHelperDAO implements GenericHelper {
*@return int representing number of rows effected by this operation
*@throws GenericEntityException
*/
@Override
public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
if (modelEntity == null || condition == null) {
return 0;
@@ -192,6 +204,7 @@ public class GenericHelperDAO implements GenericHelper {
*@param messages List to put any result messages in
*@param addMissing Flag indicating whether or not to add missing entities and fields on the server
*/
@Override
public void checkDataSource(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) throws GenericEntityException {
genericDAO.checkDb(modelEntities, messages, addMissing);
}
@@ -50,6 +50,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
genericDAO = GenericDAO.getGenericDAO(helperInfo);
}
@Override
public String getHelperName() {
return this.helperInfo.getHelperFullName();
}
@@ -57,6 +58,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
/** Read only, no creation realize on the database
*@return null
*/
@Override
public GenericValue create(GenericValue value) throws GenericEntityException {
return null;
}
@@ -65,6 +67,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
*@param primaryKey The primary key to find by.
*@return The GenericValue corresponding to the primaryKey
*/
@Override
public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException {
if (primaryKey == null) {
return null;
@@ -80,6 +83,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
*@param keys The keys, or names, of the values to retrieve; only these values will be retrieved
*@return The GenericValue corresponding to the primaryKey
*/
@Override
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException {
if (primaryKey == null) {
return null;
@@ -96,6 +100,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
*@param primaryKeys A List of primary keys to find by.
*@return List of GenericValue objects corresponding to the passed primaryKey objects
*/
@Override
public List<GenericValue> findAllByPrimaryKeys(List<GenericPK> primaryKeys) throws GenericEntityException {
if (primaryKeys == null) return null;
List<GenericValue> results = new LinkedList<>();
@@ -111,6 +116,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
/** Read only, no remove realize on the database
*@return 0
*/
@Override
public int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException {
return 0;
}
@@ -125,17 +131,20 @@ public class ReadOnlyHelperDAO implements GenericHelper {
*@return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE
* DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
*/
@Override
public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition,
EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
throws GenericEntityException {
return genericDAO.selectListIteratorByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
}
@Override
public List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne,
ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException {
return genericDAO.selectByMultiRelation(value, modelRelationOne, modelEntityOne, modelRelationTwo, modelEntityTwo, orderBy);
}
@Override
public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException {
return genericDAO.selectCountByCondition(delegator, modelEntity, whereEntityCondition, havingEntityCondition, findOptions);
}
@@ -144,6 +153,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
/** Read only, no remove realize on the database
*@return 0
*/
@Override
public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException {
return 0;
}
@@ -151,6 +161,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
/** Read only, no store realize on the database
*@return 0
*/
@Override
public int store(GenericValue value) throws GenericEntityException {
return 0;
}
@@ -158,6 +169,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
/** Read only, no store realize on the database
*@return 0
*/
@Override
public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException {
return 0;
}
@@ -167,6 +179,7 @@ public class ReadOnlyHelperDAO implements GenericHelper {
*@param messages List to put any result messages in
*@param addMissing Flag indicating whether or not to add missing entities and fields on the server by force to false on read only mode
*/
@Override
public void checkDataSource(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) throws GenericEntityException {
genericDAO.checkDb(modelEntities, messages, false);
}
@@ -188,6 +188,7 @@ public final class EntityFinderUtil {
this.ignoreExdr = FlexibleStringExpander.getInstance(conditionExprElement.getAttribute("ignore"));
}
@Override
public EntityCondition createCondition(Map<String, ? extends Object> context, ModelEntity modelEntity, ModelFieldTypeReader modelFieldTypeReader) {
if ("true".equals(this.ignoreExdr.expandString(context))) {
return null;
@@ -289,6 +290,7 @@ public final class EntityFinderUtil {
}
}
@Override
public EntityCondition createCondition(Map<String, ? extends Object> context, ModelEntity modelEntity, ModelFieldTypeReader modelFieldTypeReader) {
if (this.conditionList == null) {
return null;
@@ -320,6 +322,7 @@ public final class EntityFinderUtil {
this.fieldNameAcsr = FlexibleMapAccessor.getInstance(fieldNameAttribute);
}
@Override
public EntityCondition createCondition(Map<String, ? extends Object> context, ModelEntity modelEntity, ModelFieldTypeReader modelFieldTypeReader) {
return (EntityCondition) fieldNameAcsr.get(context);
}
@@ -362,6 +365,7 @@ public final class EntityFinderUtil {
}
}
@Override
public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
int start = getStart(context) + 1; // ELI index is one-based.
int size = getSize(context);
@@ -375,6 +379,7 @@ public final class EntityFinderUtil {
}
}
@Override
public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
List<GenericValue> result = null;
int start = getStart(context);
@@ -424,6 +429,7 @@ public final class EntityFinderUtil {
}
}
@Override
public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
int index = this.getIndex(context);
int size = this.getSize(context);
@@ -437,6 +443,7 @@ public final class EntityFinderUtil {
}
}
@Override
public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
List<GenericValue> result = null;
int index = this.getIndex(context);
@@ -461,10 +468,12 @@ public final class EntityFinderUtil {
// no parameters, nothing to do
}
@Override
public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
listAcsr.put(context, eli);
}
@Override
public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
throw new IllegalArgumentException("Cannot handle output with use-iterator when the query is cached, or the result in general is not an EntityListIterator");
}
@@ -475,6 +484,7 @@ public final class EntityFinderUtil {
// no parameters, nothing to do
}
@Override
public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
try {
listAcsr.put(context, eli.getCompleteList());
@@ -486,6 +496,7 @@ public final class EntityFinderUtil {
}
}
@Override
public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor<Object> listAcsr) {
listAcsr.put(context, results);
}
@@ -40,6 +40,7 @@ public class CursorConnection extends AbstractCursorHandler {
this.con = con;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("prepareStatement".equals(method.getName())) {
Debug.logInfo("prepareStatement", module);
@@ -41,6 +41,7 @@ public class CursorResultSet extends AbstractCursorHandler {
rs = stmt.executeQuery(query);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("close".equals(method.getName())) {
close();
@@ -46,6 +46,7 @@ public class CursorStatement extends AbstractCursorHandler {
Debug.logInfo("beganTransaction=" + beganTransaction + ", autoCommit=" + autoCommit, module);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("close".equals(method.getName())) {
stmt.getConnection().setAutoCommit(autoCommit);
@@ -429,6 +429,7 @@ public class DatabaseUtil {
for (ModelEntity curEntity: entitiesAdded) {
if (curEntity.getRelationsOneSize() > 0) {
fkIndicesFutures.add(executor.submit(new AbstractCountingCallable(curEntity, modelEntities) {
@Override
public AbstractCountingCallable call() throws Exception {
count = createForeignKeyIndices(entity, datasourceInfo.getConstraintNameClipLength(), messages);
return this;
@@ -458,6 +459,7 @@ public class DatabaseUtil {
for (ModelEntity curEntity: entitiesAdded) {
if (curEntity.getIndexesSize() > 0) {
disFutures.add(executor.submit(new AbstractCountingCallable(curEntity, modelEntities) {
@Override
public AbstractCountingCallable call() throws Exception {
count = createDeclaredIndices(entity, messages);
return this;
@@ -1017,6 +1019,7 @@ public class DatabaseUtil {
private AbstractCountingCallable createPrimaryKeyFetcher(final DatabaseMetaData dbData, final String lookupSchemaName, final boolean needsUpperCase, final Map<String, Map<String, ColumnCheckInfo>> colInfo, final Collection<String> messages, final String curTable) {
return new AbstractCountingCallable(null, null) {
@Override
public AbstractCountingCallable call() throws Exception {
if (Debug.verboseOn()) Debug.logVerbose("Fetching primary keys for " + curTable, module);
ResultSet rsPks = dbData.getPrimaryKeys(null, lookupSchemaName, curTable);
@@ -1504,6 +1507,7 @@ public class DatabaseUtil {
this.tableName = tableName;
}
@Override
public CreateTableCallable call() throws Exception {
String errMsg = createTable(entity, modelEntities, false);
if (UtilValidate.isNotEmpty(errMsg)) {
@@ -1302,6 +1302,7 @@ public class ModelEntity implements Comparable<ModelEntity>, Serializable {
return returnString.toString();
}
@Override
public int compareTo(ModelEntity otherModelEntity) {
/* This DOESN'T WORK, so forget it... using two passes
@@ -838,6 +838,7 @@ public class ModelViewEntity extends ModelEntity {
}
}
@Override
public Iterator<String> iterator() {
if (this.fieldsToExclude == null) {
return Collections.<String>emptySet().iterator();
@@ -1004,6 +1005,7 @@ public class ModelViewEntity extends ModelEntity {
this.complexAliasMembers.addAll(complexAliasMembers);
}
@Override
public void makeAliasColName(StringBuilder colNameBuffer, StringBuilder fieldTypeBuffer, ModelViewEntity modelViewEntity, ModelReader modelReader) {
if (complexAliasMembers.size() == 0) {
return;
@@ -1060,6 +1062,7 @@ public class ModelViewEntity extends ModelEntity {
/**
* Make the alias as follows: function(coalesce(entityAlias.field, defaultValue))
*/
@Override
public void makeAliasColName(StringBuilder colNameBuffer, StringBuilder fieldTypeBuffer, ModelViewEntity modelViewEntity, ModelReader modelReader) {
if(UtilValidate.isEmpty(entityAlias)
&& UtilValidate.isEmpty(field)
@@ -1173,6 +1176,7 @@ public class ModelViewEntity extends ModelEntity {
return this.keyMaps.iterator();
}
@Override
public Iterator<ModelKeyMap> iterator() {
return this.keyMaps.iterator();
}
@@ -1374,6 +1378,7 @@ public class ModelViewEntity extends ModelEntity {
this.relEntityAlias = relEntityAlias;
}
@Override
public EntityCondition createCondition(ModelFieldTypeReader modelFieldTypeReader, List<String> entityAliasStack) {
Object value = this.value;
// If IN or BETWEEN operator, see if value is a literal list and split it
@@ -1489,6 +1494,7 @@ public class ModelViewEntity extends ModelEntity {
}
}
@Override
public EntityCondition createCondition(ModelFieldTypeReader modelFieldTypeReader, List<String> entityAliasStack) {
if (this.conditionList.size() == 0) {
return null;
@@ -46,67 +46,86 @@ public class DumbTransactionFactory implements TransactionFactory {
public static final String module = DumbTransactionFactory.class.getName();
@Override
public TransactionManager getTransactionManager() {
return new TransactionManager() {
@Override
public void begin() throws NotSupportedException, SystemException {
}
@Override
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
}
@Override
public int getStatus() throws SystemException {
return TransactionUtil.STATUS_NO_TRANSACTION;
}
@Override
public Transaction getTransaction() throws SystemException {
return null;
}
@Override
public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException, SystemException {
}
@Override
public void rollback() throws IllegalStateException, SecurityException, SystemException {
}
@Override
public void setRollbackOnly() throws IllegalStateException, SystemException {
}
@Override
public void setTransactionTimeout(int i) throws SystemException {
}
@Override
public Transaction suspend() throws SystemException {
return null;
}
};
}
@Override
public UserTransaction getUserTransaction() {
return new UserTransaction() {
@Override
public void begin() throws NotSupportedException, SystemException {
}
@Override
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
}
@Override
public int getStatus() throws SystemException {
return TransactionUtil.STATUS_NO_TRANSACTION;
}
@Override
public void rollback() throws IllegalStateException, SecurityException, SystemException {
}
@Override
public void setRollbackOnly() throws IllegalStateException, SystemException {
}
@Override
public void setTransactionTimeout(int i) throws SystemException {
}
};
}
@Override
public String getTxMgrName() {
return "dumb";
}
@Override
public Connection getConnection(GenericHelperInfo helperInfo) throws SQLException, GenericEntityException {
Datasource datasourceInfo = EntityConfig.getDatasource(helperInfo.getHelperBaseName());
@@ -118,5 +137,6 @@ public class DumbTransactionFactory implements TransactionFactory {
return null;
}
@Override
public void shutdown() {}
}
@@ -79,9 +79,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
}
}
/**
* @see javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid xid, int flag)
*/
@Override
public void start(Xid xid, int flag) throws XAException {
if (this.active) {
if (this.xid != null && this.xid.equals(xid)) {
@@ -100,9 +98,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
this.start();
}
/**
* @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid xid, int flag)
*/
@Override
public void end(Xid xid, int flag) throws XAException {
if (!this.active) {
throw new XAException(XAException.XAER_PROTO);
@@ -114,9 +110,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
this.active = false;
}
/**
* @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid xid)
*/
@Override
public void forget(Xid xid) throws XAException {
if (this.xid == null || !this.xid.equals(xid)) {
throw new XAException(XAException.XAER_NOTA);
@@ -128,9 +122,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
}
}
/**
* @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid xid)
*/
@Override
public int prepare(Xid xid) throws XAException {
if (this.xid == null || !this.xid.equals(xid)) {
throw new XAException(XAException.XAER_NOTA);
@@ -138,9 +130,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
return XA_OK;
}
/**
* @see javax.transaction.xa.XAResource#recover(int flag)
*/
@Override
public Xid[] recover(int flag) throws XAException {
if (this.xid == null) {
return new Xid[0];
@@ -148,24 +138,17 @@ public abstract class GenericXaResource extends Thread implements XAResource {
return new Xid[] {this.xid};
}
/**
* @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource xaResource)
*/
@Override
public boolean isSameRM(XAResource xaResource) throws XAException {
return xaResource == this;
}
/**
* @see javax.transaction.xa.XAResource#getTransactionTimeout()
*/
@Override
public int getTransactionTimeout() throws XAException {
return this.timeout == null ? 0 : this.timeout;
}
/**
* @see javax.transaction.xa.XAResource#setTransactionTimeout(int seconds)
* Note: the valus is saved but in the current implementation this is not used.
*/
@Override
public boolean setTransactionTimeout(int seconds) throws XAException {
this.timeout = (seconds == 0 ? null : seconds);
return true;
@@ -183,14 +166,10 @@ public abstract class GenericXaResource extends Thread implements XAResource {
return this.xid;
}
/**
* @see javax.transaction.xa.XAResource#commit(javax.transaction.xa.Xid xid, boolean onePhase)
*/
@Override
public abstract void commit(Xid xid, boolean onePhase) throws XAException;
/**
* @see javax.transaction.xa.XAResource#rollback(javax.transaction.xa.Xid xid)
*/
@Override
public abstract void rollback(Xid xid) throws XAException;
/**
@@ -54,24 +54,22 @@ public class GeronimoTransactionFactory implements TransactionFactory {
}
}
/*
* @see org.apache.ofbiz.entity.transaction.TransactionFactory#getTransactionManager()
*/
@Override
public TransactionManager getTransactionManager() {
return geronimoTransactionManager;
}
/*
* @see org.apache.ofbiz.entity.transaction.TransactionFactory#getUserTransaction()
*/
@Override
public UserTransaction getUserTransaction() {
return geronimoTransactionManager;
}
@Override
public String getTxMgrName() {
return "geronimo";
}
@Override
public Connection getConnection(GenericHelperInfo helperInfo) throws SQLException, GenericEntityException {
Datasource datasourceInfo = EntityConfig.getDatasource(helperInfo.getHelperBaseName());
@@ -82,6 +80,7 @@ public class GeronimoTransactionFactory implements TransactionFactory {
return null;
}
@Override
public void shutdown() {
ConnectionFactoryLoader.getInstance().closeAll();
}
@@ -56,6 +56,7 @@ public class JNDITransactionFactory implements TransactionFactory {
protected static final ConcurrentHashMap<String, DataSource> dsCache = new ConcurrentHashMap<>();
@Override
public TransactionManager getTransactionManager() {
if (transactionManager == null) {
synchronized (JNDITransactionFactory.class) {
@@ -90,6 +91,7 @@ public class JNDITransactionFactory implements TransactionFactory {
return transactionManager;
}
@Override
public UserTransaction getUserTransaction() {
if (userTransaction == null) {
synchronized (JNDITransactionFactory.class) {
@@ -125,10 +127,12 @@ public class JNDITransactionFactory implements TransactionFactory {
return userTransaction;
}
@Override
public String getTxMgrName() {
return "jndi";
}
@Override
public Connection getConnection(GenericHelperInfo helperInfo) throws SQLException, GenericEntityException {
Datasource datasourceInfo = EntityConfig.getDatasource(helperInfo.getHelperBaseName());
@@ -207,5 +211,6 @@ public class JNDITransactionFactory implements TransactionFactory {
return null;
}
@Override
public void shutdown() {}
}
@@ -926,10 +926,12 @@ public final class TransactionUtil implements Status {
}
public static class StampClearSync implements Synchronization {
@Override
public void afterCompletion(int status) {
TransactionUtil.clearTransactionStamps();
}
@Override
public void beforeCompletion() {
}
}
@@ -941,6 +943,7 @@ public final class TransactionUtil implements Status {
this.callable = callable;
}
@Override
public V call() throws GenericEntityException {
Transaction suspended = TransactionUtil.suspend();
try {
@@ -975,6 +978,7 @@ public final class TransactionUtil implements Status {
this.printException = printException;
}
@Override
public V call() throws GenericEntityException {
boolean tx = TransactionUtil.begin(timeout);
Throwable transactionAbortCause = null;
@@ -47,6 +47,7 @@ public class Converters implements ConverterLoader {
super(JSON.class, GenericValue.class);
}
@Override
public GenericValue convert(JSON obj) throws ConversionException {
Map<String, Object> fieldMap;
try {
@@ -79,6 +80,7 @@ public class Converters implements ConverterLoader {
super(GenericValue.class, JSON.class);
}
@Override
public JSON convert(GenericValue obj) throws ConversionException {
Map<String, Object> fieldMap = new HashMap<>(obj);
fieldMap.put("_DELEGATOR_NAME_", obj.getDelegator().getDelegatorName());
@@ -96,6 +98,7 @@ public class Converters implements ConverterLoader {
super(GenericValue.class, List.class);
}
@Override
public List<GenericValue> convert(GenericValue obj) throws ConversionException {
List<GenericValue> tempList = new LinkedList<>();
tempList.add(obj);
@@ -108,6 +111,7 @@ public class Converters implements ConverterLoader {
super(GenericValue.class, Set.class);
}
@Override
public Set<GenericValue> convert(GenericValue obj) throws ConversionException {
Set<GenericValue> tempSet = new HashSet<>();
tempSet.add(obj);
@@ -120,6 +124,7 @@ public class Converters implements ConverterLoader {
super(GenericValue.class, String.class);
}
@Override
public String convert(GenericValue obj) throws ConversionException {
return obj.toString();
}
@@ -130,6 +135,7 @@ public class Converters implements ConverterLoader {
super(GenericEntity.NullField.class, Object.class);
}
@Override
public Object convert(GenericEntity.NullField obj) throws ConversionException {
return null;
}
@@ -140,11 +146,13 @@ public class Converters implements ConverterLoader {
super(Object.class, GenericEntity.NullField.class);
}
@Override
public GenericEntity.NullField convert(Object obj) throws ConversionException {
return GenericEntity.NULL_FIELD;
}
}
@Override
public void loadConverters() {
org.apache.ofbiz.base.conversion.Converters.loadContainedConverters(Converters.class);
}
@@ -157,6 +157,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
* @throws GenericEntityException
* if the {@link EntityListIterator} cannot be closed.
*/
@Override
public void close() throws GenericEntityException {
if (closed) {
String modelEntityName = modelEntity != null ? modelEntity.getEntityName() : "";
@@ -280,6 +281,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
* this.next()) != null) { ... }
*
*/
@Override
public boolean hasNext() {
if (!haveShowHasNextWarning) {
// DEJ20050207 To further discourage use of this, and to find existing use, always log a big warning showing where it is used:
@@ -306,6 +308,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
* PLEASE NOTE: Because of the nature of the JDBC ResultSet interface this method can be very inefficient.
* It is much better to just use previous() until it returns null.
*/
@Override
public boolean hasPrevious() {
try {
// do a quick game to see if the resultSet is empty:
@@ -326,6 +329,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
*
* @return the next element or null, if there is no next element.
*/
@Override
public GenericValue next() {
try {
return resultSet.next() ? currentGenericValue() : null;
@@ -341,6 +345,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
/**
* Returns the index of the next result, but does not guarantee that there will be a next result.
*/
@Override
public int nextIndex() {
try {
return currentIndex() + 1;
@@ -354,6 +359,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
* Moves the cursor to the previous position and returns the GenericValue object for that position;
* if there is no previous, returns null.
*/
@Override
public GenericValue previous() {
try {
return resultSet.previous() ? currentGenericValue() : null;
@@ -369,6 +375,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
/**
* Returns the index of the previous result, but does not guarantee that there will be a previous result.
*/
@Override
public int previousIndex() {
try {
return currentIndex() - 1;
@@ -507,6 +514,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
/**
* Unsupported {@link ListIterator#add(Object)} method.
*/
@Override
public void add(GenericValue obj) {
throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access");
}
@@ -514,6 +522,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
/**
* Unsupported {@link ListIterator#remove()} method.
*/
@Override
public void remove() {
throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access");
}
@@ -521,6 +530,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
/**
* Unsupported {@link ListIterator#set(Object)} method.
*/
@Override
public void set(GenericValue obj) {
throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access");
}
@@ -269,6 +269,7 @@ public class EntitySaxReader extends DefaultHandler {
// ======== ContentHandler interface implementation ========
@Override
public void characters(char[] values, int offset, int count) throws SAXException {
if (isParseForTemplate) {
// if null, don't worry about it
@@ -294,6 +295,7 @@ public class EntitySaxReader extends DefaultHandler {
}
}
@Override
public void endElement(String namespaceURI, String localName, String fullNameString) throws SAXException {
if (Debug.verboseOn()) Debug.logVerbose("endElement: localName=" + localName + ", fullName=" + fullNameString + ", numberRead=" + numberRead, module);
if ("entity-engine-xml".equals(fullNameString)) {
@@ -444,10 +446,12 @@ public class EntitySaxReader extends DefaultHandler {
}
}
@Override
public void setDocumentLocator(org.xml.sax.Locator locator) {
this.locator = locator;
}
@Override
public void startElement(String namepsaceURI, String localName, String fullNameString, Attributes attributes) throws SAXException {
if (Debug.verboseOn()) Debug.logVerbose("startElement: localName=" + localName + ", fullName=" + fullNameString + ", attributes=" + attributes, module);
if ("entity-engine-xml".equals(fullNameString)) {
@@ -584,15 +588,18 @@ public class EntitySaxReader extends DefaultHandler {
// ======== ErrorHandler interface implementation ========
@Override
public void error(org.xml.sax.SAXParseException exception) throws SAXException {
Debug.logWarning(exception, "Error reading XML on line " + exception.getLineNumber() + ", column " + exception.getColumnNumber(), module);
}
@Override
public void fatalError(org.xml.sax.SAXParseException exception) throws SAXException {
Debug.logError(exception, "Fatal Error reading XML on line " + exception.getLineNumber() + ", column " + exception.getColumnNumber(), module);
throw new SAXException("Fatal Error reading XML on line " + exception.getLineNumber() + ", column " + exception.getColumnNumber(), exception);
}
@Override
public void warning(org.xml.sax.SAXParseException exception) throws SAXException {
Debug.logWarning(exception, "Warning reading XML on line " + exception.getLineNumber() + ", column " + exception.getColumnNumber(), module);
}