All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.ucm.fdi.gaia.jcolibri.method.reuse.DirectAttributeCopyMethod Maven / Gradle / Ivy

Go to download

jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.

There is a newer version: 3.2
Show newest version
/**
 * DirectAttributeCopyMethod.java
 * jCOLIBRI2 framework. 
 * @author Juan A. Recio-Garc�a.
 * GAIA - Group for Artificial Intelligence Applications
 * http://gaia.fdi.ucm.es
 * 05/01/2007
 */
package es.ucm.fdi.gaia.jcolibri.method.reuse;


import org.apache.logging.log4j.LogManager;

import es.ucm.fdi.gaia.jcolibri.cbrcore.Attribute;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRQuery;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent;
import es.ucm.fdi.gaia.jcolibri.exception.AttributeAccessException;
import es.ucm.fdi.gaia.jcolibri.util.AttributeUtils;

import java.util.Collection;

/**
 * Copies the value of an attribute in the query to an attribute of a case 
 * @author Juan A. Recio-Garcia
 * @version 2.0
 *
 */
public class DirectAttributeCopyMethod {

	/**
	 * Copies the value of the querySource attribute into the caseDestination attribute of the cases. 
	 */
	public static void copyAttribute(Attribute querySource, Attribute caseDestination, CBRQuery query, Collection cases)
	{
		Object queryValue = AttributeUtils.findValue(querySource, query);
		try {
			
			for(CBRCase c: cases)
			{
				CaseComponent cc = AttributeUtils.findBelongingComponent(caseDestination, c);
				caseDestination.setValue(cc, queryValue);
			}
		} catch (AttributeAccessException e) {
			LogManager.getLogger().error(e);
		}
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy