| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package com.xpn.xwiki.plugin.charts.source; |
| 21 |
|
|
| 22 |
|
import java.lang.reflect.InvocationTargetException; |
| 23 |
|
import java.lang.reflect.Method; |
| 24 |
|
import java.util.Map; |
| 25 |
|
|
| 26 |
|
import com.xpn.xwiki.XWikiContext; |
| 27 |
|
import com.xpn.xwiki.plugin.charts.exceptions.DataSourceException; |
| 28 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 7 |
Complexity Density: 0.58 |
|
| 29 |
|
public class MainDataSourceFactory implements DataSourceFactory |
| 30 |
|
{ |
| 31 |
|
private static DataSourceFactory uniqueInstance = new MainDataSourceFactory(); |
| 32 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 33 |
0 |
private MainDataSourceFactory()... |
| 34 |
|
{ |
| 35 |
|
|
| 36 |
|
} |
| 37 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 38 |
0 |
public static DataSourceFactory getInstance()... |
| 39 |
|
{ |
| 40 |
0 |
return uniqueInstance; |
| 41 |
|
} |
| 42 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 43 |
0 |
@Override... |
| 44 |
|
public DataSource create(Map params, XWikiContext context) throws DataSourceException |
| 45 |
|
{ |
| 46 |
0 |
String type = (String) params.get("type"); |
| 47 |
0 |
if (type == null || "".equals(type)) { |
| 48 |
0 |
throw new DataSourceException("Empty datasource type"); |
| 49 |
|
} |
| 50 |
0 |
String factoryClassName = |
| 51 |
|
DataSource.class.getPackage().getName() + "." + Character.toUpperCase(type.charAt(0)) |
| 52 |
|
+ type.toLowerCase().substring(1) + "DataSourceFactory"; |
| 53 |
|
|
| 54 |
0 |
try { |
| 55 |
0 |
Class class_ = Class.forName(factoryClassName); |
| 56 |
0 |
Method method = class_.getMethod("getInstance", new Class[] {}); |
| 57 |
0 |
DataSourceFactory factory = (DataSourceFactory) method.invoke(null, new Object[] {}); |
| 58 |
0 |
return factory.create(params, context); |
| 59 |
|
} catch (InvocationTargetException e) { |
| 60 |
0 |
throw new DataSourceException(e.getTargetException()); |
| 61 |
|
} catch (Exception e) { |
| 62 |
0 |
throw new DataSourceException(e); |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
} |