<commit_before>package org.nakedobjects.distribution;

import org.nakedobjects.NakedObjects;
import org.nakedobjects.object.Naked;
import org.nakedobjects.object.NakedObject;
import org.nakedobjects.object.NakedObjectSpecification;
import org.nakedobjects.object.control.Hint;
import org.nakedobjects.object.reflect.AbstractActionPeer;
import org.nakedobjects.object.reflect.ActionPeer;
import org.nakedobjects.object.reflect.MemberIdentifier;
import org.nakedobjects.object.reflect.ReflectiveActionException;

import org.apache.log4j.Logger;


public final class ProxyAction extends AbstractActionPeer {
    final static Logger LOG = Logger.getLogger(ProxyAction.class);
    private ClientDistribution connection;
    private boolean fullProxy = false;
    private final DataFactory dataFactory;

    public ProxyAction(final ActionPeer local, final ClientDistribution connection, DataFactory objectDataFactory) {
        super(local);
        this.connection = connection;
        this.dataFactory = objectDataFactory;
    }

    public Naked execute(MemberIdentifier identifier, NakedObject target, Naked[] parameters) throws ReflectiveActionException {
        if (isPersistent(target)) {
            String[] parameterTypes = pararmeterTypes();
            Data[] parameterObjectData = parameterValues(parameters);
            ObjectData targetObjectData = connection.executeAction(NakedObjects.getCurrentSession(), getType().getName(), getName(),
                    parameterTypes, target.getOid(), target.getSpecification().getFullName(), parameterObjectData);
            NakedObject returnedObject;
            returnedObject = targetObjectData == null ? null : DataHelper.recreateObject(targetObjectData);
            return returnedObject;
        } else {
            return super.execute(identifier, target, parameters);
        }
    }

    private Data[] parameterValues(Naked[] parameters) {
        Data parameterObjectData[] = new Data[parameters.length];
        for (int i = 0; i < parameters.length; i++) {
            Naked parameter = parameters[i];
            parameterObjectData[i] = dataFactory.createData(parameter, 0);
        }
        return parameterObjectData;
    }

    private String[] pararmeterTypes() {
        NakedObjectSpecification[] parameterTypes = parameterTypes();
        String[] parameterTypeNames = new String[parameterTypes.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            parameterTypeNames[i] = parameterTypes[i].getFullName();
        }
        return parameterTypeNames;
    }

    public Hint getHint(MemberIdentifier identifier, NakedObject object, Naked[] parameters) {
        if (isPersistent(object) && fullProxy) {
            String[] parameterTypes = pararmeterTypes();
            Data[] parameterObjectData = parameterValues(parameters);
            return connection.getActionHint(NakedObjects.getCurrentSession(), getType().getName(), getName(), parameterTypes, object.getOid(), object
                    .getSpecification().getFullName(), parameterObjectData);
        } else {
            return super.getHint(identifier, object, parameters);
        }
    }

    private boolean isPersistent(NakedObject object) {
        return object.getOid() != null;
    }
}
<commit_msg>Added a flag to the Action and ActionPeer classes, to allow the framework by find out where programmer wants the method be executed.<commit_after>package org.nakedobjects.distribution;

import org.nakedobjects.NakedObjects;
import org.nakedobjects.object.Naked;
import org.nakedobjects.object.NakedObject;
import org.nakedobjects.object.NakedObjectSpecification;
import org.nakedobjects.object.control.Hint;
import org.nakedobjects.object.reflect.AbstractActionPeer;
import org.nakedobjects.object.reflect.Action;
import org.nakedobjects.object.reflect.ActionPeer;
import org.nakedobjects.object.reflect.MemberIdentifier;
import org.nakedobjects.object.reflect.ReflectiveActionException;

import org.apache.log4j.Logger;


public final class ProxyAction extends AbstractActionPeer {
    final static Logger LOG = Logger.getLogger(ProxyAction.class);
    private ClientDistribution connection;
    private boolean fullProxy = false;
    private final DataFactory dataFactory;

    public ProxyAction(final ActionPeer local, final ClientDistribution connection, DataFactory objectDataFactory) {
        super(local);
        this.connection = connection;
        this.dataFactory = objectDataFactory;
    }

    public Naked execute(MemberIdentifier identifier, NakedObject target, Naked[] parameters) throws ReflectiveActionException {
        if (executeRemotely(target)) {
            String[] parameterTypes = pararmeterTypes();
            Data[] parameterObjectData = parameterValues(parameters);
            ObjectData targetObjectData = connection.executeAction(NakedObjects.getCurrentSession(), getType().getName(), getName(),
                    parameterTypes, target.getOid(), target.getSpecification().getFullName(), parameterObjectData);
            NakedObject returnedObject;
            returnedObject = targetObjectData == null ? null : DataHelper.recreateObject(targetObjectData);
            return returnedObject;
        } else {
            return super.execute(identifier, target, parameters);
        }
    }

    private boolean executeRemotely(NakedObject target) {
        boolean remoteAsPersistent = target.getOid() != null;
        boolean remoteOverride =  getTarget() == Action.REMOTE;
        boolean localOverride =  getTarget() == Action.LOCAL;
        
        if(localOverride) {
            return false;
        }
        
        if(remoteOverride) {
            return true;
        }
        
        return remoteAsPersistent;
   }

    private Data[] parameterValues(Naked[] parameters) {
        Data parameterObjectData[] = new Data[parameters.length];
        for (int i = 0; i < parameters.length; i++) {
            Naked parameter = parameters[i];
            parameterObjectData[i] = dataFactory.createData(parameter, 0);
        }
        return parameterObjectData;
    }

    private String[] pararmeterTypes() {
        NakedObjectSpecification[] parameterTypes = parameterTypes();
        String[] parameterTypeNames = new String[parameterTypes.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            parameterTypeNames[i] = parameterTypes[i].getFullName();
        }
        return parameterTypeNames;
    }

    public Hint getHint(MemberIdentifier identifier, NakedObject target, Naked[] parameters) {
        if (executeRemotely(target) && fullProxy) {
            String[] parameterTypes = pararmeterTypes();
            Data[] parameterObjectData = parameterValues(parameters);
            return connection.getActionHint(NakedObjects.getCurrentSession(), getType().getName(), getName(), parameterTypes, target.getOid(), target
                    .getSpecification().getFullName(), parameterObjectData);
        } else {
            return super.getHint(identifier, target, parameters);
        }
    }
}

{'fraction_non_alphanumeric': 0.09115319389485585, 'fraction_numerical': 0.0011305822498586771, 'mean_word_length': 3.3631319358816274, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4895604', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1729, 'n_words': 403}