// Path: src/main/java/br/usp/ime/icdc/model/icd/Classifiable.java
// public interface Classifiable {
// 	public String getCode();
// }
// 
// Path: src/main/java/br/usp/ime/icdc/model/icd/TopographyGroup.java
// @Entity
// public class TopographyGroup implements Classifiable {
// 	@Id
// 	@GeneratedValue
// 	private Long id;
// 
// 	@Column
// 	@Index(name = "code_ndx")
// 	private String code;
// 
// 	@Column
// 	private String description;
// 	
// 	@Column
// 	@Index(name = "startcode_ndx")
// 	private Integer startCode;
// 	
// 	@Column
// 	@Index(name = "endcode_ndx")
// 	private Integer endCode;
// 	
// 	// bidirectional relationship
// 	@OneToMany(mappedBy="group")
// 	private List<TopographyCategory> category;
// 	
// 	public TopographyGroup() {
// 
// 	}
// 	
// 	public TopographyGroup(String code, String description, Integer from, Integer to) {
// 		this.code = code;
// 		this.description = description;
// 		this.startCode = from;
// 		this.endCode = to;
// 	}
// 	
// 	public void addTopographyCategory(TopographyCategory tc) {
// 		tc.setGroup(this);
// 		if (this.category == null)
// 			this.category = new ArrayList<TopographyCategory>();
// 		this.category.add(tc);
// 	}
// 	
// 	public String getCode() {
// 		return code;
// 	}
// 
// 	public String getDescription() {
// 		return description;
// 	}
// 
// 	public static void loadFromFile(File file) {
// 		List<String[]> myEntries = null;
// 		try {
// 			CSVReader reader = new CSVReader(new InputStreamReader(
// 					new FileInputStream(file), "UTF-8"));
// 			myEntries = reader.readAll();
// 			reader.close();
// 		} catch (IOException e) {
// 			// TODO Auto-generated catch block
// 			e.printStackTrace();
// 		}
// 
// 		Iterator<String[]> iter = myEntries.iterator();
// 		iter.next();
// 		
// 		DAOFactory factory = DAOFactory.getDAOFactory();
// 
// 		TopographyGroupDAO groupDao = factory.getTopographyGroupDAO();
// 		
// 		groupDao.beginTransaction();
// 		while (iter.hasNext()) {
// 			String[] entry = iter.next();
// 			String code = entry[0];
// 			
// 			int hyphenIndex = code.lastIndexOf('-');
// 			Integer from = null;
// 			Integer to = Integer.parseInt(code.substring(hyphenIndex+2));
// 			if (hyphenIndex != -1)
// 				from = Integer.parseInt(code.substring(1, hyphenIndex));
// 			else
// 				from = to;
// 			
// 			TopographyGroup t = new TopographyGroup(code, entry[1], from, to);
// 			groupDao.save(t);
// 		}
// 		groupDao.commit();
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "TopographyGroup [id=" + id + ", code=" + code
// 				+ ", description=" + description + ", startCode=" + startCode
// 				+ ", endCode=" + endCode + "]";
// 	}
// }


import java.util.List;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import br.usp.ime.icdc.model.icd.Classifiable;
import br.usp.ime.icdc.model.icd.TopographyGroup;

		return (TopographyGroup) this.session
				.createCriteria(TopographyGroup.class)
				.add(Restrictions.le("startCode", search))
				.add(Restrictions.ge("endCode", search)).uniqueResult();
	}
	
	public TopographyGroup locateCode(String code) {
		return (TopographyGroup) this.session
				.createCriteria(TopographyGroup.class)
				.add(Restrictions.eq("code", code)).uniqueResult();
	}

	public void update(TopographyGroup t) {
		this.session.update(t);
	}

	public void beginTransaction() {
		this.session.beginTransaction();
	}

	public void commit() {
		this.session.getTransaction().commit();
	}

	public void flushAndClear() {
		this.session.flush();
		this.session.clear();
	}
	
	@SuppressWarnings("unchecked")

// Path: src/main/java/br/usp/ime/icdc/model/icd/Classifiable.java
// public interface Classifiable {
// 	public String getCode();
// }
// 
// Path: src/main/java/br/usp/ime/icdc/model/icd/TopographyGroup.java
// @Entity
// public class TopographyGroup implements Classifiable {
// 	@Id
// 	@GeneratedValue
// 	private Long id;
// 
// 	@Column
// 	@Index(name = "code_ndx")
// 	private String code;
// 
// 	@Column
// 	private String description;
// 	
// 	@Column
// 	@Index(name = "startcode_ndx")
// 	private Integer startCode;
// 	
// 	@Column
// 	@Index(name = "endcode_ndx")
// 	private Integer endCode;
// 	
// 	// bidirectional relationship
// 	@OneToMany(mappedBy="group")
// 	private List<TopographyCategory> category;
// 	
// 	public TopographyGroup() {
// 
// 	}
// 	
// 	public TopographyGroup(String code, String description, Integer from, Integer to) {
// 		this.code = code;
// 		this.description = description;
// 		this.startCode = from;
// 		this.endCode = to;
// 	}
// 	
// 	public void addTopographyCategory(TopographyCategory tc) {
// 		tc.setGroup(this);
// 		if (this.category == null)
// 			this.category = new ArrayList<TopographyCategory>();
// 		this.category.add(tc);
// 	}
// 	
// 	public String getCode() {
// 		return code;
// 	}
// 
// 	public String getDescription() {
// 		return description;
// 	}
// 
// 	public static void loadFromFile(File file) {
// 		List<String[]> myEntries = null;
// 		try {
// 			CSVReader reader = new CSVReader(new InputStreamReader(
// 					new FileInputStream(file), "UTF-8"));
// 			myEntries = reader.readAll();
// 			reader.close();
// 		} catch (IOException e) {
// 			// TODO Auto-generated catch block
// 			e.printStackTrace();
// 		}
// 
// 		Iterator<String[]> iter = myEntries.iterator();
// 		iter.next();
// 		
// 		DAOFactory factory = DAOFactory.getDAOFactory();
// 
// 		TopographyGroupDAO groupDao = factory.getTopographyGroupDAO();
// 		
// 		groupDao.beginTransaction();
// 		while (iter.hasNext()) {
// 			String[] entry = iter.next();
// 			String code = entry[0];
// 			
// 			int hyphenIndex = code.lastIndexOf('-');
// 			Integer from = null;
// 			Integer to = Integer.parseInt(code.substring(hyphenIndex+2));
// 			if (hyphenIndex != -1)
// 				from = Integer.parseInt(code.substring(1, hyphenIndex));
// 			else
// 				from = to;
// 			
// 			TopographyGroup t = new TopographyGroup(code, entry[1], from, to);
// 			groupDao.save(t);
// 		}
// 		groupDao.commit();
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "TopographyGroup [id=" + id + ", code=" + code
// 				+ ", description=" + description + ", startCode=" + startCode
// 				+ ", endCode=" + endCode + "]";
// 	}
// }


// Path: src/main/java/br/usp/ime/icdc/dao/TopographyGroupDAO.java
import java.util.List;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import br.usp.ime.icdc.model.icd.Classifiable;
import br.usp.ime.icdc.model.icd.TopographyGroup;

		return (TopographyGroup) this.session
				.createCriteria(TopographyGroup.class)
				.add(Restrictions.le("startCode", search))
				.add(Restrictions.ge("endCode", search)).uniqueResult();
	}
	
	public TopographyGroup locateCode(String code) {
		return (TopographyGroup) this.session
				.createCriteria(TopographyGroup.class)
				.add(Restrictions.eq("code", code)).uniqueResult();
	}

	public void update(TopographyGroup t) {
		this.session.update(t);
	}

	public void beginTransaction() {
		this.session.beginTransaction();
	}

	public void commit() {
		this.session.getTransaction().commit();
	}

	public void flushAndClear() {
		this.session.flush();
		this.session.clear();
	}
	
	@SuppressWarnings("unchecked")

	public List<Classifiable> list() {
