<commit_before>package com.inepex.ineForm.client.table;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
import com.inepex.ineForm.client.datamanipulator.events.KeyValueObjectListModifiedEvent;
import com.inepex.ineForm.client.table.ServerSideDataConnector.DataConnectorReadyCallback;
import com.inepex.ineFrame.client.async.AsyncStatusIndicator;
import com.inepex.ineFrame.client.async.IneDispatchBase.SuccessCallback;
import com.inepex.ineom.shared.assistedobject.AssistedObject;
import com.inepex.ineom.shared.assistedobject.KeyValueObject;
import com.inepex.ineom.shared.descriptor.CustomKVOObjectDesc;
import com.inepex.ineom.shared.dispatch.ManipulationTypes;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectList;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectListResult;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectManipulation;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectManipulationResult;

public abstract class IneDataConnector extends AsyncDataProvider<AssistedObject> {

	protected class ObjectManipulationCallback extends SuccessCallback<ObjectManipulationResult> {

		private final ObjectManipulation currentManipulation;
		private final ManipulateResultCallback currentCallback;

		public ObjectManipulationCallback(ObjectManipulation currentManipulation, ManipulateResultCallback currentCallback) {
			this.currentManipulation = currentManipulation;
			this.currentCallback = currentCallback;
		}

		@Override
		public void onSuccess(ObjectManipulationResult result) {
			if (result!=null && result.isSuccess() && (result.getValidationResult()==null || result.getValidationResult().isValid())) {
				if (currentManipulation.getObject()!=null
						&& currentManipulation.getObject().isNew()){
					rowCount++;
					resultMap.put(result.getObjectsNewState().getId(), resultList.size());
					resultList.add(result.getObjectsNewState());					
					
				}
				
				if (currentManipulation.getManipulationType() == ManipulationTypes.DELETE && rowCount > 0){
					--rowCount;
					resultList.remove(resultMap.get(currentManipulation.getObject().getId()).intValue());
					resultMap.remove(currentManipulation.getObject().getId());
				}
			}
			if (currentCallback != null)
				currentCallback.onManipulationResult(result);

			updateDisplaysAndfireListChangedEvent();
		}

	}

	private final String descriptorName;
	protected final EventBus eventBus;

	protected boolean suppotsIsDeleted = false;
	protected boolean showDeletedActive = false;

	protected String orderKey = null;
	protected boolean orderDescending = false;

	protected AssistedObject searchParameters;
	
	/**
	 * map assisted object id to list index
	 */
	protected HashMap<Long, Integer> resultMap = new HashMap<Long, Integer>();
	
	protected List<AssistedObject> resultList = new ArrayList<AssistedObject>();
	
	protected Long rowCount;
	
	protected ObjectList objectList = null;
	protected ObjectManipulation objectManipulation = null;

	protected AsyncStatusIndicator customListingStatusIndicator = null;
	protected AsyncStatusIndicator customManipulateStatusIndicator = null;
	
	private boolean isPaging = true;
	
	private DataConnectorReadyCallback callback;	
	
	private boolean firstCall = true;

	public IneDataConnector(EventBus eventBus, String descriptorName) {
		this.eventBus = eventBus;
		this.descriptorName = descriptorName;
<commit_msg>NullPointerException on modification success callback fixed<commit_after>package com.inepex.ineForm.client.table;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
import com.inepex.ineForm.client.datamanipulator.events.KeyValueObjectListModifiedEvent;
import com.inepex.ineForm.client.table.ServerSideDataConnector.DataConnectorReadyCallback;
import com.inepex.ineFrame.client.async.AsyncStatusIndicator;
import com.inepex.ineFrame.client.async.IneDispatchBase.SuccessCallback;
import com.inepex.ineom.shared.assistedobject.AssistedObject;
import com.inepex.ineom.shared.assistedobject.KeyValueObject;
import com.inepex.ineom.shared.descriptor.CustomKVOObjectDesc;
import com.inepex.ineom.shared.dispatch.ManipulationTypes;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectList;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectListResult;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectManipulation;
import com.inepex.ineom.shared.dispatch.interfaces.ObjectManipulationResult;

public abstract class IneDataConnector extends AsyncDataProvider<AssistedObject> {

	protected class ObjectManipulationCallback extends SuccessCallback<ObjectManipulationResult> {

		private final ObjectManipulation currentManipulation;
		private final ManipulateResultCallback currentCallback;

		public ObjectManipulationCallback(ObjectManipulation currentManipulation, ManipulateResultCallback currentCallback) {
			this.currentManipulation = currentManipulation;
			this.currentCallback = currentCallback;
		}

		@Override
		public void onSuccess(ObjectManipulationResult result) {
			if (result!=null && result.isSuccess() && (result.getValidationResult()==null || result.getValidationResult().isValid())) {
				if (currentManipulation.getObject()!=null
						&& currentManipulation.getObject().isNew()){
					rowCount++;
					resultMap.put(result.getObjectsNewState().getId(), resultList.size());
					resultList.add(result.getObjectsNewState());					
					
				}
				
				if (currentManipulation.getManipulationType() == ManipulationTypes.DELETE && rowCount > 0){
					--rowCount;
					resultList.remove(resultMap.get(currentManipulation.getObject().getId()).intValue());
					resultMap.remove(currentManipulation.getObject().getId());
				}
			}
			if (currentCallback != null)
				currentCallback.onManipulationResult(result);

			updateDisplaysAndfireListChangedEvent();
		}

	}

	private final String descriptorName;
	protected final EventBus eventBus;

	protected boolean suppotsIsDeleted = false;
	protected boolean showDeletedActive = false;

	protected String orderKey = null;
	protected boolean orderDescending = false;

	protected AssistedObject searchParameters;
	
	/**
	 * map assisted object id to list index
	 */
	protected HashMap<Long, Integer> resultMap = new HashMap<Long, Integer>();
	
	protected List<AssistedObject> resultList = new ArrayList<AssistedObject>();
	
	protected Long rowCount = new Long(0L);
	
	protected ObjectList objectList = null;
	protected ObjectManipulation objectManipulation = null;

	protected AsyncStatusIndicator customListingStatusIndicator = null;
	protected AsyncStatusIndicator customManipulateStatusIndicator = null;
	
	private boolean isPaging = true;
	
	private DataConnectorReadyCallback callback;	
	
	private boolean firstCall = true;

	public IneDataConnector(EventBus eventBus, String descriptorName) {
		this.eventBus = eventBus;
		this.descriptorName = descriptorName;

{'fraction_non_alphanumeric': 0.08979192850160592, 'fraction_numerical': 0.00041893590280687055, 'mean_word_length': 6.000977517106549, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '2771976', 'n_tokens_mistral': 2184, 'n_tokens_neox': 1969, 'n_words': 369}