Skip to content
Open
Show file tree
Hide file tree
Changes from all 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,12 +43,13 @@
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.DelegatorProvider;
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 DelegatorProvider {

enum OperationType { INSERT, UPDATE, DELETE }

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
@@ -0,0 +1,16 @@
package org.apache.ofbiz.entity.util;

import org.apache.ofbiz.entity.Delegator;

/**
* Interface for classes that hold a delegator that is meant to be used by other classes (for queries for example)
*/
public interface DelegatorProvider {

/**
* Gets the Delegator associated with current object instance
* @return Delegator associated with current object instance
*/
Delegator getDelegator();

}
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 delegatorProvider The delegator provider instance to use for the query
*/
public static EntityQuery use(Delegator delegator) {
return new EntityQuery(delegator);
public static EntityQuery use(DelegatorProvider delegatorProvider) {
return new EntityQuery(delegatorProvider.getDelegator());
}

/** Construct an EntityQuery object for use against the specified Delegator
Expand Down
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.DelegatorProvider;
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 DelegatorProvider {

/**
* 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