1    package com.instantbank.collections.ach;
2    
3    import java.util.HashMap;
4    import java.util.Iterator;
5    import java.util.LinkedList;
6    import java.util.List;
7    import java.sql.SQLException;
8    import javax.naming.NamingException;
9    import com.instantbank.collections.util.InstantbankException;
10   import com.instantbank.collections.util.LongWrapper;
11   
12   public class CompanySystemManager {
13   
14     private static final HashMap companySystemTable = new HashMap(5);
15   
16     // Build a list of company system views, and only once. Should rarely change
17     public static final synchronized List getCompanySystemViews(long companyId)
18        throws SQLException, NamingException, InstantbankException {
19   
20       LongWrapper lw = new LongWrapper(companyId);
21       List companySystems = (List)companySystemTable.get(lw);
22       if(companySystems == null) {
23         companySystems = new LinkedList();
24         List keys = CompanySystemDO.getPrimaryKeys(companyId);
25         for(Iterator walker = keys.iterator(); walker.hasNext(); ) {
26           LongWrapper key = (LongWrapper)walker.next();
27           CompanySystemDO dataObject = new CompanySystemDO(key.getValue());
28           AchDAO.populateByPrimaryKey(dataObject);
29           String desc = SystemDAO.retrieveSystemDesc(dataObject.getCompanySystem().getSystemId());
30           companySystems.add(new CompanySystemView(dataObject, desc));
31         }
32         companySystemTable.put(lw, companySystems);
33       }
34       return companySystems;
35     }
36   }
37