1 package org
.argeo
.server
.dao
;
3 import java
.util
.ArrayList
;
4 import java
.util
.HashMap
;
8 import org
.apache
.commons
.logging
.Log
;
9 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.ArgeoException
;
12 public abstract class AbstractTabularDaoSupport
extends
13 AbstractMemoryDaoSupport
{
14 private final static Log log
= LogFactory
15 .getLog(AbstractTabularDaoSupport
.class);
17 private Map
<String
, List
<Object
>> tabularView
= new HashMap
<String
, List
<Object
>>();
20 protected Object
findInternalRef(Reference reference
) {
21 TabularInternalReference tabReference
= (TabularInternalReference
) reference
;
22 return getFromTabularView(tabReference
.getTargetTableName(),
23 tabReference
.getTargetRow());
26 protected Object
getFromTabularView(String tableName
, Integer row
) {
27 return tabularView
.get(tableName
).get(row
- 2);
30 protected void registerInTabularView(String tableName
, Object object
) {
31 if (!tabularView
.containsKey(tableName
))
32 tabularView
.put(tableName
, new ArrayList
<Object
>());
33 tabularView
.get(tableName
).add(object
);
36 protected Class
<?
> findClassToInstantiate(String tableName
) {
37 // TODO: ability to map sheet names and class names
38 String className
= tableName
;
41 clss
= getClassLoader().loadClass(className
);
43 } catch (ClassNotFoundException e
) {
47 scannedPkgs
: for (String pkg
: getScannedPackages()) {
49 clss
= getClassLoader().loadClass(pkg
.trim() + "." + className
);
51 } catch (ClassNotFoundException e
) {
53 if (log
.isTraceEnabled())
54 log
.trace(e
.getMessage());
59 throw new ArgeoException("Cannot find a class for table "
65 protected static class TabularInternalReference
extends Reference
{
66 private String targetTableName
;
67 private Integer targetRow
;
69 public TabularInternalReference(Object object
, String property
,
70 String targetSheet
, Integer targetRow
) {
71 super(object
, property
, null);
72 this.targetTableName
= targetSheet
;
73 this.targetRow
= targetRow
;
76 public String
getTargetTableName() {
77 return targetTableName
;
80 public Integer
getTargetRow() {