Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@
import org.apache.ofbiz.entity.util.EntityFindOptions;
import org.apache.ofbiz.entity.util.EntityListIterator;
import org.apache.ofbiz.entity.util.EntityStoreOptions;
import org.apache.ofbiz.entity.util.Queryable;
import org.apache.ofbiz.entity.util.SequenceUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public interface Delegator {
public interface Delegator extends Queryable {

enum OperationType { INSERT, UPDATE, DELETE }

Delegator getDelegator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This declaration is not required since it is an inherited method.


void clearAllCacheLinesByDummyPK(Collection<GenericPK> dummyPKs);

void clearAllCacheLinesByValue(Collection<GenericValue> values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ public String getGroupHelperName(String groupName) {
return this.delegatorInfo.getGroupDataSource(groupName);
}

@Override
public Delegator getDelegator() {
return this;
}

@Override
public GenericHelperInfo getGroupHelperInfo(String entityGroupName) {
if (entityGroupName == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ public class EntityQuery {
private Integer offset;
private Integer limit;


/** Construct an EntityQuery object for use against the specified Delegator
* @param delegator The delegator instance to use for the query
* @param queryable The delegator instance to use for the query
*/
public static EntityQuery use(Delegator delegator) {
return new EntityQuery(delegator);
public static EntityQuery use(Queryable queryable) {
return new EntityQuery(queryable.getDelegator());
}

/** Construct an EntityQuery object for use against the specified Delegator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.apache.ofbiz.entity.util;

import org.apache.ofbiz.entity.Delegator;

/**
* Interface used for the <code>EntityQuery</code> to set the delegator to yse for the query.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Javadoc should just describe the capability of the interface without directly mentioning the classes that may use it (such as EntityQuery). There are also a few typos, such as: "yse", "easyer".

* Allows easyer and shorter query instructions, like calling an <code>EntityQuery</code> with a dispatcher.
*/
public interface Queryable {

/**
* Gets the GenericEntityDelegator associated with this dispatcher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Javadoc is not correct as it mentions GenericEntityDelegator rather than Delegator and it mentions "this dispatcher" which is out of context in this interface.

* @return GenericEntityDelegator associated with this dispatcher
*/
Delegator getDelegator();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.Map;

import org.apache.ofbiz.entity.Delegator;
import org.apache.ofbiz.entity.util.Queryable;
import org.apache.ofbiz.security.Security;
import org.apache.ofbiz.service.jms.JmsListenerFactory;
import org.apache.ofbiz.service.job.JobManager;
Expand All @@ -32,7 +32,7 @@
* by calling the {@link org.apache.ofbiz.service.ServiceDispatcher#getLocalDispatcher(String, Delegator)}
* factory method.</p>
*/
public interface LocalDispatcher {
public interface LocalDispatcher extends Queryable {

/**
* Initialize a dispatch context for this dispatch after the creation is ok
Expand Down Expand Up @@ -343,12 +343,6 @@ void schedule(String serviceName, Map<String, ? extends Object> context, long st
*/
JmsListenerFactory getJMSListeneFactory();

/**
* Gets the GenericEntityDelegator associated with this dispatcher
* @return GenericEntityDelegator associated with this dispatcher
*/
Delegator getDelegator();


/**
* Gets the Security object associated with this dispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void setUp() throws GenericEntityException {
list.add(genericValue);
when(delegator.findList(any(), any(), any(), any(), any(), any(), Mockito.anyBoolean()))
.thenReturn(list);
when(delegator.getDelegator()).thenReturn(delegator);
context = new HashMap<>();
context.put("delegator", delegator);
}
Expand Down
Loading