
package usda.weru.remoteDataAccess.jdbc.soil;

import java.nio.file.Path;
import usda.weru.remoteDataAccess.RdaHierarchicalItem;
import usda.weru.remoteDataAccess.jdbc.soil.JdbcSoilInterface.SoilCatParms;
import usda.weru.remoteDataAccess.jdbc.soil.JdbcSoilInterface.soilElementType;
import usda.weru.util.WepsMessageLog;

/**
 *
 * @author mhaas
 */
public class JdbcSoilHierarchicalItem extends RdaHierarchicalItem {
    
    JdbcSoilInterface.soilElementType ifType;
    JdbcSoilInterface soilIf;
    
    public JdbcSoilHierarchicalItem(String name, JdbcSoilHierarchicalItem parent) {
        this (new SoilCatParms(name), parent);
    }
    public JdbcSoilHierarchicalItem(JdbcSoilInterface.SoilCatParms parms, JdbcSoilHierarchicalItem parent) {
        super(parms.name, parent, false);
        
        switch (parent.ifType) {
            case database:
                ifType = soilElementType.legend;
                soilIf = new JdbcSoilInterfaceLegend (parent.soilIf, parms);
                break;
            case legend:
                ifType = soilElementType.mapunit;
                soilIf = new JdbcSoilInterfaceMapunit (parent.soilIf, parms);
                break;
            case mapunit:
                ifType = soilElementType.component;
                this.isFile = true;
                soilIf = new JdbcSoilInterfaceComponent (parent.soilIf, parms);
                break;
            case component:
                ifType = soilElementType.component;
                this.isFile = true;
                soilIf = new JdbcSoilInterfaceComponent (parent.soilIf, parms);
        }
    }
    
    public JdbcSoilHierarchicalItem(String name, JdbcSoilInputController controller, JdbcSoilInterface soilIf) {
        super(name, controller);
        
        this.soilIf = soilIf;
        this.ifType = soilIf.ifType;
    }
    
    @Override
    public void setDestinationPath (Path destPath) {
        soilIf.interfaceSetDestinationPath(destPath);
    }

    public WepsMessageLog getItemLog () {
        return ((JdbcSoilInputController)controller).getFileLog(this);
    }
    
}
