From 1345baa9d7795183b1ef3701a3a4cf079d8e5903 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Mon, 15 Sep 2008 13:28:12 +0000 Subject: [PATCH] HR: * added MHRAttribute * added MHRDepartment + caching support --- .../org/eevolution/model/MHRAttribute.java | 53 +++++++++++ .../org/eevolution/model/MHRDepartment.java | 90 +++++++++++++++++++ base/src/org/eevolution/model/MHRProcess.java | 2 +- 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 base/src/org/eevolution/model/MHRAttribute.java create mode 100644 base/src/org/eevolution/model/MHRDepartment.java diff --git a/base/src/org/eevolution/model/MHRAttribute.java b/base/src/org/eevolution/model/MHRAttribute.java new file mode 100644 index 0000000000..94b1283e8b --- /dev/null +++ b/base/src/org/eevolution/model/MHRAttribute.java @@ -0,0 +1,53 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.eevolution.model; + +import java.sql.ResultSet; +import java.util.Properties; + +/** + * HR Attribute Model + * @author Cristina Ghita, www.arhipac.ro + * + */ +public class MHRAttribute extends X_HR_Attribute +{ + private static final long serialVersionUID = 1L; + + /** + * @param ctx + * @param HR_Attribute_ID + * @param trxName + */ + public MHRAttribute(Properties ctx, int HR_Attribute_ID, String trxName) + { + super(ctx, HR_Attribute_ID, trxName); + } + + /** + * @param ctx + * @param rs + * @param trxName + */ + public MHRAttribute(Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } + + @Override + public I_HR_Concept getHR_Concept() + { + return MHRConcept.get(getCtx(), getHR_Concept_ID()); + } +} diff --git a/base/src/org/eevolution/model/MHRDepartment.java b/base/src/org/eevolution/model/MHRDepartment.java new file mode 100644 index 0000000000..0becb4862b --- /dev/null +++ b/base/src/org/eevolution/model/MHRDepartment.java @@ -0,0 +1,90 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.eevolution.model; + +import java.sql.ResultSet; +import java.util.List; +import java.util.Properties; + +import org.compiere.model.Query; +import org.compiere.util.CCache; +import org.compiere.util.Env; + +/** + * @author Cristina Ghita, www.arhipac.ro + * + */ +public class MHRDepartment extends X_HR_Department +{ + private static final long serialVersionUID = 1L; + + public static List getAll(Properties ctx) + { + List list = new Query(Env.getCtx(), X_HR_Department.Table_Name, "AD_Client_ID=?", null) + .setParameters(new Object[] {Env.getAD_Client_ID(ctx)}) + .setOrderBy(COLUMNNAME_Name) + .list(); + for (MHRDepartment dep : list) + { + s_cache.put(dep.get_ID(), dep); + } + return list; + } + + public static MHRDepartment get(Properties ctx, int HR_Department_ID) + { + if (HR_Department_ID <= 0) + { + return null; + } + + if (s_cache.size() == 0) + { + getAll(ctx); + } + MHRDepartment dep = s_cache.get(HR_Department_ID); + if (dep != null) + { + return dep; + } + dep = new MHRDepartment(ctx, HR_Department_ID, null); + if (dep.get_ID() == HR_Department_ID) + { + s_cache.put(HR_Department_ID, dep); + } + return dep; + } + + private static CCache s_cache = new CCache(Table_Name, 50, 0); + + /** + * @param ctx + * @param HR_Department_ID + * @param trxName + */ + public MHRDepartment(Properties ctx, int HR_Department_ID, String trxName) + { + super(ctx, HR_Department_ID, trxName); + } + + /** + * @param ctx + * @param rs + * @param trxName + */ + public MHRDepartment(Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } +} diff --git a/base/src/org/eevolution/model/MHRProcess.java b/base/src/org/eevolution/model/MHRProcess.java index cc9a2fc57b..caffd3d4a4 100644 --- a/base/src/org/eevolution/model/MHRProcess.java +++ b/base/src/org/eevolution/model/MHRProcess.java @@ -282,7 +282,7 @@ public class MHRProcess extends X_HR_Process implements DocAction { log.info("Skip concept "+concept+" - attribute not found"); continue; } - X_HR_Attribute att = new X_HR_Attribute(Env.getCtx(),m_attribute,get_TrxName()); + MHRAttribute att = new MHRAttribute(Env.getCtx(),m_attribute,get_TrxName()); if(!concept.getType().equals(MHRConcept.TYPE_RuleEngine)) // Not Rule Engine - Only put HashTable {