Some Java

Java code posted by Dusty Pearce
created at 14 Jan 21:14, updated at 03 Feb 12:15

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.wfinance.portal.business;

import java.util.HashMap;

import com.wfinance.portal.common.utils.ListUtilities;
import com.wfinance.portal.common.utils.SQLUtilities;
import com.wfinance.portal.persistence.dao.TableRefDAO;
import com.wfinance.portal.persistence.pojo.tref.TableSP1;

/**
 * TableRefHelper.java - Charge les tables de référence en mémoire.
 * 
 * <p>
 * ---<br>
 * Any disclosure, use, dissemination or reproduction of this material is
 * strictly prohibited without prior consent.<br>
 * Copyright (c) 2002 WFinance and WFinance Conseil. All rights reserved.
 * <p>
 * See&nbsp; <a href="http://www.wfinance.fr" target="_parent">WFINANCE Web Site</a>
 * <br>
 * ---
 * <p>
 * 
 * @author <a href="mailto:deoliveira@wfinance.fr">Edouard De Oliveira</a>
 * 
 * @version $Revision: 1.1.2.1 $, $Date: 2009/01/26 11:37:08 $
 */
public class TableRefHelper
{
  private HashMap periodiciteMap;
  private HashMap typeOperationAutoMap;
  private HashMap typeProduitMap;
  private HashMap typeSousProduitMap;
  private HashMap transactionMap;  

  private TableRefDAO tableRefDAO;
  
  public void setTableRefDAO(TableRefDAO tableRefDAO)
  {
    this.tableRefDAO = tableRefDAO;
  }

  public void loadTables() {
    typeOperationAutoMap = ListUtilities.listToHashMap(tableRefDAO.
        getTableSP1(ConstantesMetier.TABLESP1_ID_TABLE_TYPE_OPERATION_AUTO), TableSP1.class, "getCle");
    
    typeProduitMap = ListUtilities.listToHashMap(tableRefDAO.
        getTableSP1(ConstantesMetier.TABLESP1_ID_TABLE_TYPE_PRODUIT), TableSP1.class, "getCle");
    
    typeSousProduitMap = ListUtilities.listToHashMap(tableRefDAO.
        getTableSP1(ConstantesMetier.TABLESP1_ID_TABLE_TYPE_SOUS_PRODUIT), TableSP1.class, "getCle");
    
    periodiciteMap = ListUtilities.listToHashMap(tableRefDAO.
        getTableSP1(ConstantesMetier.TABLESP1_ID_TABLE_PERIODICITE), TableSP1.class, "getCle"); 
    
    transactionMap = ListUtilities.listToHashMap(tableRefDAO.
        getTableSP1(ConstantesMetier.TABLESP1_ID_TABLE_TRANSACTION), TableSP1.class, "getCle");
  }
  
  private String getLibelleCourt(HashMap m, String code) {
    if (code == null)
      return "";
    else
    {
      TableSP1 val = (TableSP1) m.get(
          SQLUtilities.whiteSpacePrefixedString(code.trim(), 15));
      if (val != null)
        return val.getLibelleCourt();
      else
        return "";
    }
  }
  
  public String getLibelleCourtTransaction(String code) {
    return getLibelleCourt(transactionMap, code);
  }
  
  public String getLibelleCourtTypeOperationAuto(String code) {
    return getLibelleCourt(typeOperationAutoMap, code);
  }
  
  public String getLibelleCourtPeriodicite(String code) {
    return getLibelleCourt(periodiciteMap, code);
  }
  
  public String getLibelleCourtTypeProduit(String code) {
    if (code == null)
      return "";
    else
    {
      TableSP1 val = (TableSP1) typeProduitMap.get("004"+code);
      if (val != null)
        return val.getLibelleCourt();
      else
        return "";
    }
  }

  public String getLibelleCourtTypeSousProduit(String code) {
    if (code == null)
      return "";
    else
    {
      TableSP1 val = (TableSP1) typeSousProduitMap.get("004"+code);
      if (val != null)
        return val.getLibelleCourt();
      else
        return "";
    }
  }  
}
3.19 KB in 9 ms with coderay