<commit_before>package am.app.mappingEngine;

import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.swing.SwingWorker;

import am.AMException;
import am.Utility;
import am.app.Core;
import am.app.mappingEngine.Mapping.MappingRelation;
import am.app.mappingEngine.MatcherChangeEvent.EventType;
import am.app.mappingEngine.oneToOneSelection.MappingMWBM;
import am.app.mappingEngine.oneToOneSelection.MaxWeightBipartiteMatching;
import am.app.mappingEngine.qualityEvaluation.QualityEvaluationData;
import am.app.mappingEngine.referenceAlignment.MatchingPair;
import am.app.mappingEngine.referenceAlignment.ReferenceEvaluationData;
import am.app.mappingEngine.similarityMatrix.ArraySimilarityMatrix;
import am.app.mappingEngine.similarityMatrix.SparseMatrix;
import am.app.ontology.Node;
import am.app.ontology.Ontology;
import am.app.ontology.instance.Instance;
import am.app.ontology.instance.InstanceDataset;
import am.userInterface.MatchingProgressDisplay;

/**
 * transient data are not taken into account while serializing/deserializing the matcher
 * taking transient keyword out of an object means that either you make sure that or you just make it serializable
 * Michele  
 */
public abstract class AbstractMatcher extends SwingWorker<Void, Void> implements Matcher{
	
	/**
	 * Version identifier for this serializable class
	 */
	private static final long serialVersionUID = 1L;
	
	/**Unique identifier of the algorithm used in the JTable list as index
	 * if an algorithm gets deleted we have to decrease the index of all others by one
	 * */
	protected int index;
	/**Name of the algorithm, there should be also a final static String in the instance class
	 * in the constructor of the non-abstract class should happen "name = FINALNAME"
	 * */
	protected MatchersRegistry registryEntry;
	protected String name;
	/**User mapping should be the only one with this variable equal to false*/
	protected boolean isAutomatic;
	/**True if the algorithm needs additional parameter other than threshold, in this case the developer must develop a JFrame to let the user define them*/
	protected boolean needsParam;
	/**Parameter of this method, if needsParam this item will be generated by the userinterface if not this will be automatically generated with default values*/
	protected transient AbstractParameters param;
	/**Developer will have to instantiate this object in the constructor with real parameterpanel for the method which needs param, if a method don't needs param you don't have to touch this attribute*/
	protected transient AbstractMatcherParametersPanel parametersPanel;
	/**True means that AM should show its alignments*/
	protected boolean isShown;
	protected boolean modifiedByUser;
	//protected double threshold;
	
	/**ANY means any number of relations for source or target*/
	public final static int ANY_INT = Integer.MAX_VALUE;
	//protected int maxSourceAlign;
	//protected int maxTargetAlign;
	
	/**Contain alignments, NULL if alignment has not been calculated*/
	protected transient Alignment<Mapping> propertiesAlignmentSet;
	protected transient Alignment<Mapping> classesAlignmentSet;
	protected transient List<MatchingPair> instanceAlignmentSet;
	
	/**Structure containing similarity values between classes nodes, matrix[source][target]
	 * should not be accessible outside of this class, the system should only be able to access alignments sets
	 * */
	protected SimilarityMatrix classesMatrix;
	/**Structure containing similarity values between classes nodes, matrix[source][target]*/
	protected SimilarityMatrix propertiesMatrix;
	
	/** The ontologies to be matched. */
	protected transient Ontology sourceOntology;
	protected transient Ontology targetOntology;
	
	protected transient InstanceDataset sourceInstanceDataset;
	protected transient InstanceDataset targetInstanceDataset;
	
	// TODO: Move as many field variables into AbstractParameters as we can.  -- Cosmin. 9/19/2011
	/**If the algo calculates prop alignments*/
	protected boolean alignProp;
	/**If the algo calculates prop alignments*/
	protected boolean alignClass;
	/** True if the matcher will match instances, false otherwise. */
	protected boolean alignInstances;
	/***Some algorithms may need other algorithms as input*/
	protected transient List<AbstractMatcher> inputMatchers;
	/**Minum and maximum number of input matchers
	 * a generic matcher which doesn't need any inputs should have 0, 0
	 * */
	protected int minInputMatchers;
	protected int maxInputMatchers;
	/**Variables needed to calculate execution time, executionTime = (end - start)/ unitMeasure, start has to be init in beforeAlign() and end in aferSelect()*/
	protected long start;
	protected long end;
	protected long executionTime;
	/**Keeps info about reference evaluation of the matcher. is null until the algorithm gets evaluated*/
	protected transient ReferenceEvaluationData refEvaluation;
	/**Keeps info about the quality eval of the matcher. null if the algo is not evaluated*/
	protected transient QualityEvaluationData qualEvaluation;
	/**Graphical color for nodes mapped by this matcher and alignments, this value is set by the MatcherFactory and modified  by the table so a developer just have to pass it as aparameter for the constructor*/
	protected Color color; 
	/**
	 * the matchers combined for example in the LWC matcher can have this set to false, because the partial matchings are not needed. 
	   this parameter is mainly used in batchmode. For the UI has to be set to TRUE. Therefore, the paramter can be set to false, but should always be init to true.
	 *  **/
	protected boolean performSelection;
	
	/** If true, the progress display may not be updated faster than once every 500ms. */
	protected boolean useProgressDelay = true;
	
	/** A thread group used in threaded execution mode. */
	private transient ThreadGroup threadGroup;
	
	public void setPerformSelection(boolean performSelection) {
		this.performSelection = performSelection;
	}
	public void setUseProgressDelay(boolean d ) { useProgressDelay = d; }<commit_msg>made the thread group protected.<commit_after>package am.app.mappingEngine;

import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.swing.SwingWorker;

import am.AMException;
import am.Utility;
import am.app.Core;
import am.app.mappingEngine.Mapping.MappingRelation;
import am.app.mappingEngine.MatcherChangeEvent.EventType;
import am.app.mappingEngine.oneToOneSelection.MappingMWBM;
import am.app.mappingEngine.oneToOneSelection.MaxWeightBipartiteMatching;
import am.app.mappingEngine.qualityEvaluation.QualityEvaluationData;
import am.app.mappingEngine.referenceAlignment.MatchingPair;
import am.app.mappingEngine.referenceAlignment.ReferenceEvaluationData;
import am.app.mappingEngine.similarityMatrix.ArraySimilarityMatrix;
import am.app.mappingEngine.similarityMatrix.SparseMatrix;
import am.app.ontology.Node;
import am.app.ontology.Ontology;
import am.app.ontology.instance.Instance;
import am.app.ontology.instance.InstanceDataset;
import am.userInterface.MatchingProgressDisplay;

/**
 * transient data are not taken into account while serializing/deserializing the matcher
 * taking transient keyword out of an object means that either you make sure that or you just make it serializable
 * Michele  
 */
public abstract class AbstractMatcher extends SwingWorker<Void, Void> implements Matcher{
	
	/**
	 * Version identifier for this serializable class
	 */
	private static final long serialVersionUID = 1L;
	
	/**Unique identifier of the algorithm used in the JTable list as index
	 * if an algorithm gets deleted we have to decrease the index of all others by one
	 * */
	protected int index;
	/**Name of the algorithm, there should be also a final static String in the instance class
	 * in the constructor of the non-abstract class should happen "name = FINALNAME"
	 * */
	protected MatchersRegistry registryEntry;
	protected String name;
	/**User mapping should be the only one with this variable equal to false*/
	protected boolean isAutomatic;
	/**True if the algorithm needs additional parameter other than threshold, in this case the developer must develop a JFrame to let the user define them*/
	protected boolean needsParam;
	/**Parameter of this method, if needsParam this item will be generated by the userinterface if not this will be automatically generated with default values*/
	protected transient AbstractParameters param;
	/**Developer will have to instantiate this object in the constructor with real parameterpanel for the method which needs param, if a method don't needs param you don't have to touch this attribute*/
	protected transient AbstractMatcherParametersPanel parametersPanel;
	/**True means that AM should show its alignments*/
	protected boolean isShown;
	protected boolean modifiedByUser;
	//protected double threshold;
	
	/**ANY means any number of relations for source or target*/
	public final static int ANY_INT = Integer.MAX_VALUE;
	//protected int maxSourceAlign;
	//protected int maxTargetAlign;
	
	/**Contain alignments, NULL if alignment has not been calculated*/
	protected transient Alignment<Mapping> propertiesAlignmentSet;
	protected transient Alignment<Mapping> classesAlignmentSet;
	protected transient List<MatchingPair> instanceAlignmentSet;
	
	/**Structure containing similarity values between classes nodes, matrix[source][target]
	 * should not be accessible outside of this class, the system should only be able to access alignments sets
	 * */
	protected SimilarityMatrix classesMatrix;
	/**Structure containing similarity values between classes nodes, matrix[source][target]*/
	protected SimilarityMatrix propertiesMatrix;
	
	/** The ontologies to be matched. */
	protected transient Ontology sourceOntology;
	protected transient Ontology targetOntology;
	
	protected transient InstanceDataset sourceInstanceDataset;
	protected transient InstanceDataset targetInstanceDataset;
	
	// TODO: Move as many field variables into AbstractParameters as we can.  -- Cosmin. 9/19/2011
	/**If the algo calculates prop alignments*/
	protected boolean alignProp;
	/**If the algo calculates prop alignments*/
	protected boolean alignClass;
	/** True if the matcher will match instances, false otherwise. */
	protected boolean alignInstances;
	/***Some algorithms may need other algorithms as input*/
	protected transient List<AbstractMatcher> inputMatchers;
	/**Minum and maximum number of input matchers
	 * a generic matcher which doesn't need any inputs should have 0, 0
	 * */
	protected int minInputMatchers;
	protected int maxInputMatchers;
	/**Variables needed to calculate execution time, executionTime = (end - start)/ unitMeasure, start has to be init in beforeAlign() and end in aferSelect()*/
	protected long start;
	protected long end;
	protected long executionTime;
	/**Keeps info about reference evaluation of the matcher. is null until the algorithm gets evaluated*/
	protected transient ReferenceEvaluationData refEvaluation;
	/**Keeps info about the quality eval of the matcher. null if the algo is not evaluated*/
	protected transient QualityEvaluationData qualEvaluation;
	/**Graphical color for nodes mapped by this matcher and alignments, this value is set by the MatcherFactory and modified  by the table so a developer just have to pass it as aparameter for the constructor*/
	protected Color color; 
	/**
	 * the matchers combined for example in the LWC matcher can have this set to false, because the partial matchings are not needed. 
	   this parameter is mainly used in batchmode. For the UI has to be set to TRUE. Therefore, the paramter can be set to false, but should always be init to true.
	 *  **/
	protected boolean performSelection;
	
	/** If true, the progress display may not be updated faster than once every 500ms. */
	protected boolean useProgressDelay = true;
	
	/** A thread group used in threaded execution mode. */
	protected transient ThreadGroup threadGroup;
	
	public void setPerformSelection(boolean performSelection) {
		this.performSelection = performSelection;
	}
	public void setUseProgressDelay(boolean d ) { useProgressDelay = d; }
{'fraction_non_alphanumeric': 0.06255478524185194, 'fraction_numerical': 0.0020718782373097457, 'mean_word_length': 5.068665377176015, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6077472', 'n_tokens_mistral': 3179, 'n_tokens_neox': 3008, 'n_words': 1382}