es.ucm.fdi.gaia.jcolibri.method.reuse.DirectAttributeCopyMethod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jCOLIBRI Show documentation
Show all versions of jCOLIBRI Show documentation
jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.
/**
* 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);
}
}
}