package org.pp.modules.dev.model;

import java.util.List;

import org.pp.modules.dev.base.BaseModels;
import org.pp.modules.dev.service.FieldService;
import org.pp.modules.dev.service.ModuleService;
import org.pp.modules.dev.model.Field;
import org.pp.modules.dev.model.Module;

/**
 * Generated by JFinal.
 */
@SuppressWarnings("serial")
public class Models extends BaseModels<Models> {

	private Module module;
	private List<Field> fields;
	private List<Validation> valids;
	
	public Module getModule() {
		if(module == null && getModuleId() != null) {
			module = ModuleService.dao.findById(getModuleId());
		}
		
		return module;
		
	}
	public void setModule(Module module) {
		this.module = module;
	}

	public List<Field> getFields() {
		return fields;
	}

	public void setFields(List<Field> fields) {
		this.fields = fields;
	}
	public void loadFields() {
		if(fields == null) {
			fields = FieldService.dao.find("SELECT * FROM dev_field WHERE model_id=?", getId());
		}
	}
	public List<Validation> getValids() {
		return valids;
	}
	public void setValids(List<Validation> valids) {
		this.valids = valids;
	}
}
